--- deliantra/Deliantra-Client/Client.xs 2006/08/19 03:57:25 1.148 +++ deliantra/Deliantra-Client/Client.xs 2006/10/09 23:30:44 1.161 @@ -3,6 +3,7 @@ # define _WIN32_WINNT 0x0500 // needed to get win2000 api calls # include # include +# include # pragma warning(disable:4244) #endif @@ -171,9 +172,10 @@ } maptex; typedef struct { - uint16_t darkness; + uint32_t player; mapface face[3]; - uint8_t stat_width, stat_hp; + uint16_t darkness; + uint8_t stat_width, stat_hp, flags; } mapcell; typedef struct { @@ -316,6 +318,8 @@ cell->darkness = 0; cell->stat_hp = 0; + cell->flags = 0; + cell->player = 0; } } } @@ -650,6 +654,35 @@ #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); @@ -761,9 +794,13 @@ _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 = CFPlus PACKAGE = CFPlus::Font @@ -1245,14 +1282,14 @@ 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; @@ -1275,7 +1312,7 @@ mapcell *cell; int x, y, flags; - while (data < data_end) + while (data < data_end - 1) { flags = (data [0] << 8) + data [1]; data += 2; @@ -1288,10 +1325,8 @@ { if (!cell->darkness) { + memset (cell, 0, sizeof (*cell)); cell->darkness = 256; - cell->face [0] = 0; - cell->face [1] = 0; - cell->face [2] = 0; } //TODO: don't trust server data to be in-range(!) @@ -1316,6 +1351,15 @@ } 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 @@ -1343,10 +1387,7 @@ } } else - { - cell->darkness = 0; - cell->stat_hp = 0; - } + cell->darkness = 0; } } @@ -1459,15 +1500,13 @@ 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); } @@ -1476,12 +1515,32 @@ 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 ); + } + } } } glEnd (); glDisable (GL_TEXTURE_2D); + glDisable (GL_BLEND); // top layer: overlays such as the health bar for (y = 0; y < sh; y++) @@ -1502,19 +1561,17 @@ int width = cell->stat_width * 32; int thick = sh / 28 + 1 + cell->stat_width; - glColor4ub (0, 0, 0, 127); - glRectf (px + 1, py, - px + width - 1, py + thick + 2); + glColor3ub (0, 0, 0); + glRectf (px + 1, py - thick - 2, + px + width - 1, py); - glColor4ub (cell->stat_hp, 255 - cell->stat_hp, 0, 255); + glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); glRectf (px + 2, - py + 1, - px + width - 2 - cell->stat_hp * (width - 4) / 255, py + thick + 1); + py - thick - 1, + px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); } } } - - glDisable (GL_BLEND); } void