--- deliantra/Deliantra-Client/Client.xs 2006/04/17 21:52:42 1.47 +++ deliantra/Deliantra-Client/Client.xs 2006/04/18 00:14:16 1.48 @@ -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 @@ -99,7 +111,7 @@ int texs; maptex *tex; - uint32_t rows; + int32_t rows; maprow *row; } *CFClient__Map; @@ -204,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) @@ -211,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) @@ -238,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 () @@ -582,17 +597,19 @@ 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 @@ -640,15 +657,17 @@ { 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) { @@ -748,15 +767,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 @@ -775,12 +799,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) @@ -796,7 +818,7 @@ ? 255 - FOW_DARKNESS : 255 - cell->darkness; - mapface face = cell->face [z]; + face = cell->face [z]; if (face) { @@ -866,7 +888,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; @@ -910,13 +931,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