--- deliantra/Deliantra-Client/Client.xs 2006/04/12 20:42:52 1.23 +++ deliantra/Deliantra-Client/Client.xs 2006/04/13 00:25:28 1.28 @@ -3,6 +3,7 @@ #include "XSUB.h" #include +#include #include #include @@ -12,15 +13,13 @@ #include #include -#include -#include -#include - #include #include #include #include +#include + static PangoContext *context; static PangoFontMap *fontmap; @@ -58,6 +57,26 @@ if (!*h) *h = 1; } +typedef struct { + uint16_t face[3]; + uint8_t darkness; + uint8_t padding; +} mapcell; + +typedef struct { + uint32_t cols; + mapcell *col; +} maprow; + +typedef struct map { + int x, y, w, h; + int faces; + GLint *face; + + uint32_t rows; + maprow *row; +} *CFClient__Map; + MODULE = CFClient PACKAGE = CFClient PROTOTYPES: ENABLE @@ -151,7 +170,7 @@ SDL_LockSurface (surface2); PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); SDL_UnlockSurface (surface2); - PUSHs (sv_2mortal (newSViv (surface->format->Amask ? GL_RGBA : GL_RGB))); + 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))); @@ -159,6 +178,16 @@ SDL_FreeSurface (surface2); } +void +fatal (char *message) + CODE: +#ifdef WIN32 + MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); +#else + fprintf (stderr, "%s\n", message); +#endif + exit (1); + MODULE = CFClient PACKAGE = CFClient::Layout CFClient::Layout @@ -296,3 +325,42 @@ glTexCoord2d (s, 0); glVertex2d (x + w, y ); glEnd (); } + +MODULE = CFClient PACKAGE = CFClient::Map + +CFClient::Map +new (SV *class, int map_width, int map_height) + CODE: + New (0, RETVAL, 1, struct map); + RETVAL->x = 0; + RETVAL->y = 0; + RETVAL->w = map_width; + RETVAL->h = map_height; + RETVAL->faces = 0; + RETVAL->face = 0; + + RETVAL->rows = 0; + RETVAL->row = 0; + OUTPUT: + RETVAL + +void +DESTROY (CFClient::Map self) + CODE: +{ + int r, c; + + Safefree (self->face); + for (r = 0; r < self->rows; r++) + { + maprow *row = self->row + r; + if (!row) + continue; + + Safefree (row->col); + } + + Safefree (self->row); + Safefree (self); +} +