--- deliantra/Deliantra-Client/Client.xs 2006/04/12 23:32:27 1.27 +++ deliantra/Deliantra-Client/Client.xs 2006/04/13 00:25:28 1.28 @@ -18,6 +18,8 @@ #include #include +#include + static PangoContext *context; static PangoFontMap *fontmap; @@ -55,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 @@ -303,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); +} +