--- deliantra/Deliantra-Client/Client.xs 2006/07/05 03:01:01 1.128 +++ deliantra/Deliantra-Client/Client.xs 2006/12/08 15:07:08 1.166 @@ -1,14 +1,21 @@ #ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN # define _WIN32_WINNT 0x0500 // needed to get win2000 api calls # include # include +# include # pragma warning(disable:4244) +# pragma warning(disable:4761) #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#ifdef _WIN32 +# undef pipe +#endif + #include #include #include @@ -33,18 +40,9 @@ # 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 -#include "glext.h" - -#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ +#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ #define FOW_DARKNESS 32 @@ -82,10 +80,10 @@ #include "pango-fontmap.c" #include "pango-render.c" -typedef Mix_Chunk *CFClient__MixChunk; -typedef Mix_Music *CFClient__MixMusic; +typedef Mix_Chunk *CFPlus__MixChunk; +typedef Mix_Music *CFPlus__MixMusic; -typedef PangoFontDescription *CFClient__Font; +typedef PangoFontDescription *CFPlus__Font; static int shape_attr_p (PangoLayoutRun *run) @@ -109,10 +107,10 @@ PangoLayout *pl; float r, g, b, a; // default color for rgba mode int base_height; - CFClient__Font font; -} *CFClient__Layout; + CFPlus__Font font; +} *CFPlus__Layout; -static CFClient__Font default_font; +static CFPlus__Font default_font; static PangoContext *opengl_context; static PangoFontMap *opengl_fontmap; @@ -127,7 +125,7 @@ } static void -layout_update_font (CFClient__Layout self) +layout_update_font (CFPlus__Layout self) { /* use a random scale factor to account for unknown descenders, 0.8 works * reasonably well with bitstream vera @@ -141,14 +139,21 @@ } static void -layout_get_pixel_size (CFClient__Layout self, int *w, int *h) +layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) { - pango_layout_get_pixel_size (self->pl, w, h); + PangoRectangle rect; + + // get_pixel_* wrongly rounds down + pango_layout_get_extents (self->pl, 0, &rect); - if (!*w) *w = 1; - if (!*h) *h = 1; + rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE; + rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE; - *w = (*w + 3) & ~3; + if (!rect.width) rect.width = 1; + if (!rect.height) rect.height = 1; + + *w = rect.width; + *h = rect.height; } typedef uint16_t mapface; @@ -161,8 +166,10 @@ } maptex; typedef struct { - int16_t darkness; + uint32_t player; mapface face[3]; + uint16_t darkness; + uint8_t stat_width, stat_hp, flags; } mapcell; typedef struct { @@ -181,7 +188,7 @@ int32_t rows; maprow *row; -} *CFClient__Map; +} *CFPlus__Map; static char * prepend (char *ptr, int sze, int inc) @@ -209,7 +216,7 @@ #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) static maprow * -map_get_row (CFClient__Map self, int y) +map_get_row (CFPlus__Map self, int y) { if (0 > y) { @@ -257,13 +264,13 @@ } static mapcell * -map_get_cell (CFClient__Map self, int x, int y) +map_get_cell (CFPlus__Map self, int x, int y) { return row_get_cell (map_get_row (self, y), x); } static void -map_clear (CFClient__Map self) +map_clear (CFPlus__Map self) { int r; @@ -281,10 +288,11 @@ } static void -map_blank (CFClient__Map self, int x0, int y0, int w, int h) +map_blank (CFPlus__Map self, int x0, int y0, int w, int h) { int x, y; maprow *row; + mapcell *cell; for (y = y0; y < y0 + h; y++) if (y >= 0) @@ -300,7 +308,12 @@ if (x >= row->c1) break; - row->col[x - row->c0].darkness = -1; + cell = row->col + x - row->c0; + + cell->darkness = 0; + cell->stat_hp = 0; + cell->flags = 0; + cell->player = 0; } } } @@ -348,13 +361,13 @@ return n + 1; } -MODULE = CFClient PACKAGE = CFClient +MODULE = CFPlus PACKAGE = CFPlus PROTOTYPES: ENABLE BOOT: { - HV *stash = gv_stashpv ("CFClient", 1); + HV *stash = gv_stashpv ("CFPlus", 1); static const struct { const char *name; IV iv; @@ -465,6 +478,13 @@ newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); } +int +in_destruct () + CODE: + RETVAL = PL_main_cv == Nullcv; + OUTPUT: + RETVAL + NV floor (NV x) NV ceil (NV x) @@ -504,6 +524,10 @@ SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); +#if SDL_VERSION_ATLEAST(1,2,10) + SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); + SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); +#endif SDL_EnableUNICODE (1); SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); @@ -600,7 +624,7 @@ break; } - XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); + XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); } } @@ -624,9 +648,38 @@ #endif void +win32_proxy_info () + PPCODE: +{ +#ifdef _WIN32 + char buffer[2048]; + DWORD buflen; + + EXTEND (SP, 3); + + buflen = sizeof (buffer); + if (InternetQueryOption (0, INTERNET_OPTION_PROXY, (void *)buffer, &buflen)) + if (((INTERNET_PROXY_INFO *)buffer)->dwAccessType == INTERNET_OPEN_TYPE_PROXY) + { + PUSHs (newSVpv (((INTERNET_PROXY_INFO *)buffer)->lpszProxy, 0)); + + buflen = sizeof (buffer); + if (InternetQueryOption (0, INTERNET_OPTION_PROXY_USERNAME, (void *)buffer, &buflen)) + { + PUSHs (newSVpv (buffer, 0)); + + buflen = sizeof (buffer); + if (InternetQueryOption (0, INTERNET_OPTION_PROXY_PASSWORD, (void *)buffer, &buflen)) + PUSHs (newSVpv (buffer, 0)); + } + } +#endif +} + +void add_font (char *file) CODE: - FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ + FcConfigAppFontAddFile (0, (const FcChar8 *)file); void load_image_inline (SV *image_) @@ -678,15 +731,15 @@ assert (surface2->pitch == surface2->w * 4); - EXTEND (SP, 5); + SDL_LockSurface (surface2); + EXTEND (SP, 6); PUSHs (sv_2mortal (newSViv (surface2->w))); PUSHs (sv_2mortal (newSViv (surface2->h))); - 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_RGBA : GL_RGB))); PUSHs (sv_2mortal (newSViv (GL_RGBA))); PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); + SDL_UnlockSurface (surface2); SDL_FreeSurface (surface); SDL_FreeSurface (surface2); @@ -735,13 +788,17 @@ _exit (1); void -_exit (int retval) +_exit (int retval = 0) CODE: +#ifdef WIN32 + ExitThread (retval); // unclean, please beam me up +#else _exit (retval); +#endif -MODULE = CFClient PACKAGE = CFClient::Font +MODULE = CFPlus PACKAGE = CFPlus::Font -CFClient::Font +CFPlus::Font new_from_file (SV *class, char *path, int id = 0) CODE: { @@ -754,23 +811,23 @@ RETVAL void -DESTROY (CFClient::Font self) +DESTROY (CFPlus::Font self) CODE: pango_font_description_free (self); void -make_default (CFClient::Font self) +make_default (CFPlus::Font self) CODE: default_font = self; -MODULE = CFClient PACKAGE = CFClient::Layout +MODULE = CFPlus PACKAGE = CFPlus::Layout void -clear_font_cache () +reset_glyph_cache () CODE: tc_clear (); -CFClient::Layout +CFPlus::Layout new (SV *class) CODE: New (0, RETVAL, 1, struct cf_layout); @@ -789,13 +846,13 @@ RETVAL void -DESTROY (CFClient::Layout self) +DESTROY (CFPlus::Layout self) CODE: g_object_unref (self->pl); Safefree (self); void -set_text (CFClient::Layout self, SV *text_) +set_text (CFPlus::Layout self, SV *text_) CODE: { STRLEN textlen; @@ -805,7 +862,7 @@ } void -set_markup (CFClient::Layout self, SV *text_) +set_markup (CFPlus::Layout self, SV *text_) CODE: { STRLEN textlen; @@ -815,7 +872,7 @@ } void -set_shapes (CFClient::Layout self, ...) +set_shapes (CFPlus::Layout self, ...) CODE: { PangoAttrList *attrs = 0; @@ -860,7 +917,7 @@ } void -get_shapes (CFClient::Layout self) +get_shapes (CFPlus::Layout self) PPCODE: { PangoLayoutIter *iter = pango_layout_get_iter (self->pl); @@ -874,6 +931,7 @@ PangoRectangle extents; pango_layout_iter_get_run_extents (iter, 0, &extents); + EXTEND (SP, 2); PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); } @@ -884,7 +942,7 @@ } int -has_wrapped (CFClient::Layout self) +has_wrapped (CFPlus::Layout self) CODE: { int lines = 1; @@ -899,7 +957,7 @@ RETVAL SV * -get_text (CFClient::Layout self) +get_text (CFPlus::Layout self) CODE: RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); sv_utf8_decode (RETVAL); @@ -907,7 +965,7 @@ RETVAL void -set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) +set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) CODE: self->r = r; self->g = g; @@ -915,7 +973,7 @@ self->a = a; void -set_font (CFClient::Layout self, CFClient::Font font = 0) +set_font (CFPlus::Layout self, CFPlus::Font font = 0) CODE: if (self->font != font) { @@ -924,7 +982,7 @@ } void -set_height (CFClient::Layout self, int base_height) +set_height (CFPlus::Layout self, int base_height) CODE: if (self->base_height != base_height) { @@ -933,22 +991,22 @@ } void -set_width (CFClient::Layout self, int max_width = -1) +set_width (CFPlus::Layout self, int max_width = -1) CODE: pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); void -set_indent (CFClient::Layout self, int indent) +set_indent (CFPlus::Layout self, int indent) CODE: pango_layout_set_indent (self->pl, indent * PANGO_SCALE); void -set_spacing (CFClient::Layout self, int spacing) +set_spacing (CFPlus::Layout self, int spacing) CODE: pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); void -set_ellipsise (CFClient::Layout self, int ellipsise) +set_ellipsise (CFPlus::Layout self, int ellipsise) CODE: pango_layout_set_ellipsize (self->pl, ellipsise == 1 ? PANGO_ELLIPSIZE_START @@ -958,12 +1016,12 @@ ); void -set_single_paragraph_mode (CFClient::Layout self, int spm) +set_single_paragraph_mode (CFPlus::Layout self, int spm) CODE: pango_layout_set_single_paragraph_mode (self->pl, !!spm); void -size (CFClient::Layout self) +size (CFPlus::Layout self) PPCODE: { int w, h; @@ -976,7 +1034,7 @@ } int -descent (CFClient::Layout self) +descent (CFPlus::Layout self) CODE: { PangoRectangle rect; @@ -988,18 +1046,18 @@ RETVAL int -xy_to_index (CFClient::Layout self, int x, int y) +xy_to_index (CFPlus::Layout self, int x, int y) CODE: { int index, trailing; pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); - RETVAL = index; + RETVAL = index + trailing; } OUTPUT: RETVAL void -cursor_pos (CFClient::Layout self, int index) +cursor_pos (CFPlus::Layout self, int index) PPCODE: { PangoRectangle strong_pos; @@ -1012,15 +1070,55 @@ } void -render (CFClient::Layout self, float x, float y) +index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) + PPCODE: +{ + int line, x; + + pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); + /* pango bug: line is between 1..numlines, not 0..numlines-1 */ + + EXTEND (SP, 2); + PUSHs (sv_2mortal (newSViv (line - 1))); + PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); +} + +void +line_x_to_index (CFPlus::Layout self, int line, int x) + PPCODE: +{ + PangoLayoutLine *lp; + int index, trailing; + + if (line < 0) + XSRETURN_EMPTY; + + if (!(lp = pango_layout_get_line (self->pl, line))) + XSRETURN_EMPTY; /* do better */ + + pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); + + EXTEND (SP, 2); + if (GIMME_V == G_SCALAR) + PUSHs (sv_2mortal (newSViv (index + trailing))); + else + { + PUSHs (sv_2mortal (newSViv (index))); + PUSHs (sv_2mortal (newSViv (trailing))); + } +} + +void +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 = CFClient PACKAGE = CFClient::Texture +MODULE = CFPlus PACKAGE = CFPlus::Texture void pad2pot (SV *data_, SV *w_, SV *h_) @@ -1108,16 +1206,16 @@ } } -MODULE = CFClient PACKAGE = CFClient::Map +MODULE = CFPlus PACKAGE = CFPlus::Map -CFClient::Map -new (SV *class, int map_width, int map_height) +CFPlus::Map +new (SV *class) CODE: New (0, RETVAL, 1, struct map); RETVAL->x = 0; RETVAL->y = 0; - RETVAL->w = map_width; - RETVAL->h = map_height; + RETVAL->w = 0; + RETVAL->h = 0; RETVAL->ox = 0; RETVAL->oy = 0; RETVAL->faces = 8192; @@ -1130,7 +1228,7 @@ RETVAL void -DESTROY (CFClient::Map self) +DESTROY (CFPlus::Map self) CODE: { map_clear (self); @@ -1140,12 +1238,18 @@ } void -clear (CFClient::Map self) +resize (CFPlus::Map self, int map_width, int map_height) + CODE: + self->w = map_width; + self->h = map_height; + +void +clear (CFPlus::Map self) CODE: map_clear (self); void -set_face (CFClient::Map self, int face, int texid) +set_face (CFPlus::Map self, int face, int texid) CODE: { while (self->faces <= face) @@ -1158,7 +1262,7 @@ } void -set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) +set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) CODE: { while (self->texs <= texid) @@ -1192,7 +1296,7 @@ } int -ox (CFClient::Map self) +ox (CFPlus::Map self) ALIAS: oy = 1 x = 2 @@ -1213,18 +1317,18 @@ RETVAL void -scroll (CFClient::Map self, int dx, int dy) +scroll (CFPlus::Map self, int dx, int dy) CODE: { if (dx > 0) - map_blank (self, self->x, self->y, dx - 1, self->h); + map_blank (self, self->x, self->y, dx, self->h); else if (dx < 0) - map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); + map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h); if (dy > 0) - map_blank (self, self->x, self->y, self->w, dy - 1); + map_blank (self, self->x, self->y, self->w, dy); else if (dy < 0) - map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); + map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy); self->ox += dx; self->x += dx; self->oy += dy; self->y += dy; @@ -1239,7 +1343,7 @@ } void -map1a_update (CFClient::Map self, SV *data_) +map1a_update (CFPlus::Map self, SV *data_, int extmap) CODE: { uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); @@ -1247,7 +1351,7 @@ mapcell *cell; int x, y, flags; - while (data < data_end) + while (data < data_end - 1) { flags = (data [0] << 8) + data [1]; data += 2; @@ -1258,18 +1362,54 @@ if (flags & 15) { - if (cell->darkness < 0) + if (!cell->darkness) { - cell->darkness = 0; - cell->face [0] = 0; - cell->face [1] = 0; - cell->face [2] = 0; + memset (cell, 0, sizeof (*cell)); + cell->darkness = 256; } - 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 & 0x3f; + + if (cmd < 4) + cell->darkness = 255 - ext * 64 + 1; + else if (cmd == 5) // health + { + cell->stat_width = 1; + cell->stat_hp = *data++; + } + else if (cmd == 6) // monster width + cell->stat_width = *data++ + 1; + else if (cmd == 0x47) // monster width + { + if (*data == 4) + ; // decode player tag + + data += *data + 1; + } + else if (cmd == 8) // cell flags + cell->flags = *data++; + else if (ext & 0x40) // unknown, multibyte => skip + data += *data + 1; + else + data++; + } + while (ext & 0x80); + } + else + cell->darkness = *data++ + 1; + } + if (flags & 4) { cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; @@ -1286,12 +1426,12 @@ } } else - cell->darkness = -1; + cell->darkness = 0; } } SV * -mapmap (CFClient::Map self, int x0, int y0, int w, int h) +mapmap (CFPlus::Map self, int x0, int y0, int w, int h) CODE: { int x1, x; @@ -1351,27 +1491,13 @@ RETVAL void -draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) +draw (CFPlus::Map self, int mx, int my, int sw, int sh) CODE: { - int vx, vy; int x, y, z; int last_name; mapface face; - vx = self->x + self->w / 2 - sw / 2 - shift_x; - vy = self->y + self->h / 2 - sh / 2 - shift_y; - - /* - int vx = self->vx = self->w >= sw - ? self->x + (self->w - sw) / 2 - : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx)); - - int vy = self->vy = self->h >= sh - ? self->y + (self->h - sh) / 2 - : MIN (self->y, MAX (self->y + self->h - sh + 1, self->vy)); - */ - glColor4ub (255, 255, 255, 255); glEnable (GL_BLEND); @@ -1383,31 +1509,32 @@ last_name = 0; + mx += self->x; + my += self->y; + for (z = 0; z < 3; z++) for (y = 0; y < sh; y++) - if (0 <= y + vy && y + vy < self->rows) + if (0 <= y + my && y + my < self->rows) { - maprow *row = self->row + (y + vy); + maprow *row = self->row + (y + my); for (x = 0; x < sw; x++) - if (row->c0 <= x + vx && x + vx < row->c1) + if (row->c0 <= x + mx && x + mx < row->c1) { - mapcell *cell = row->col + (x + vx - row->c0); + mapcell *cell = row->col + (x + mx - row->c0); face = cell->face [z]; - if (face) + if (face && face < self->texs) { maptex tex = self->tex [face]; - int px = (x + 1) * 32 - tex.w; int py = (y + 1) * 32 - tex.h; if (last_name != tex.name) { glEnd (); - last_name = tex.name; - glBindTexture (GL_TEXTURE_2D, last_name); + glBindTexture (GL_TEXTURE_2D, last_name = tex.name); glBegin (GL_QUADS); } @@ -1416,6 +1543,25 @@ glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); } + + if (cell->flags && z == 2) + { + if (cell->flags & 1) + { + maptex tex = self->tex [1]; + int px = (x + 1) * 32 - tex.w + 2; + int py = (y + 1) * 32 - tex.h - 6; + + glEnd (); + glBindTexture (GL_TEXTURE_2D, last_name = tex.name); + glBegin (GL_QUADS); + + glTexCoord2f (0 , 0 ); glVertex2f (px , py ); + glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); + glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); + glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); + } + } } } @@ -1423,10 +1569,41 @@ glDisable (GL_TEXTURE_2D); glDisable (GL_BLEND); + + // top layer: overlays such as the health bar + for (y = 0; y < sh; y++) + if (0 <= y + my && y + my < self->rows) + { + maprow *row = self->row + (y + my); + + for (x = 0; x < sw; x++) + if (row->c0 <= x + mx && x + mx < row->c1) + { + mapcell *cell = row->col + (x + mx - row->c0); + + int px = x * 32; + int py = y * 32; + + if (cell->stat_hp) + { + int width = cell->stat_width * 32; + int thick = sh / 28 + 1 + cell->stat_width; + + glColor3ub (0, 0, 0); + glRectf (px + 1, py - thick - 2, + px + width - 1, py); + + glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); + glRectf (px + 2, + py - thick - 1, + px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); + } + } + } } void -draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) +draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) CODE: { static float color[16][3] = { @@ -1486,10 +1663,9 @@ } void -fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) +fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) PPCODE: { - int vx, vy; int x, y; int sw4 = (sw + 3) & ~3; SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); @@ -1499,22 +1675,22 @@ 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; + mx += self->x; + my += self->y; for (y = 0; y < sh; y++) - if (0 <= y + vy && y + vy < self->rows) + if (0 <= y + my && y + my < self->rows) { - maprow *row = self->row + (y + vy); + maprow *row = self->row + (y + my); for (x = 0; x < sw; x++) - if (row->c0 <= x + vx && x + vx < row->c1) + if (row->c0 <= x + mx && x + mx < row->c1) { - mapcell *cell = row->col + (x + vx - row->c0); + mapcell *cell = row->col + (x + mx - 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; } } @@ -1525,7 +1701,7 @@ } SV * -get_rect (CFClient::Map self, int x0, int y0, int w, int h) +get_rect (CFPlus::Map self, int x0, int y0, int w, int h) CODE: { int x, y, x1, y1; @@ -1597,7 +1773,7 @@ RETVAL void -set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) +set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) PPCODE: { int x, y, z; @@ -1639,9 +1815,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++) { @@ -1656,9 +1832,9 @@ } } -MODULE = CFClient PACKAGE = CFClient::MixChunk +MODULE = CFPlus PACKAGE = CFPlus::MixChunk -CFClient::MixChunk +CFPlus::MixChunk new_from_file (SV *class, char *path) CODE: RETVAL = Mix_LoadWAV (path); @@ -1666,25 +1842,25 @@ RETVAL void -DESTROY (CFClient::MixChunk self) +DESTROY (CFPlus::MixChunk self) CODE: Mix_FreeChunk (self); int -volume (CFClient::MixChunk self, int volume = -1) +volume (CFPlus::MixChunk self, int volume = -1) CODE: RETVAL = Mix_VolumeChunk (self, volume); OUTPUT: RETVAL int -play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) +play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) CODE: RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); OUTPUT: RETVAL -MODULE = CFClient PACKAGE = CFClient::MixMusic +MODULE = CFPlus PACKAGE = CFPlus::MixMusic int volume (int volume = -1) @@ -1693,7 +1869,7 @@ OUTPUT: RETVAL -CFClient::MixMusic +CFPlus::MixMusic new_from_file (SV *class, char *path) CODE: RETVAL = Mix_LoadMUS (path); @@ -1701,22 +1877,22 @@ RETVAL void -DESTROY (CFClient::MixMusic self) +DESTROY (CFPlus::MixMusic self) CODE: Mix_FreeMusic (self); int -play (CFClient::MixMusic self, int loops = -1) +play (CFPlus::MixMusic self, int loops = -1) CODE: RETVAL = Mix_PlayMusic (self, loops); OUTPUT: RETVAL -MODULE = CFClient PACKAGE = CFClient::OpenGL +MODULE = CFPlus PACKAGE = CFPlus::OpenGL BOOT: { - HV *stash = gv_stashpv ("CFClient::OpenGL", 1); + HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); static const struct { const char *name; IV iv; @@ -1789,6 +1965,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), @@ -1908,10 +2085,7 @@ b *= a; } // microsoft visual "c" rounds instead of truncating... - glColor4ub (MIN ((int)(r * 256.f), 255), - MIN ((int)(g * 256.f), 255), - MIN ((int)(b * 256.f), 255), - MIN ((int)(a * 256.f), 255)); + glColor4f (r, g, b, a); void glInterleavedArrays (int format, int stride, char *data) @@ -1998,4 +2172,3 @@ void glCallList (int list) -