ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.23 by root, Wed Apr 12 20:42:52 2006 UTC vs.
Revision 1.28 by root, Thu Apr 13 00:25:28 2006 UTC

1#include "EXTERN.h" 1#include "EXTERN.h"
2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5#include <string.h> 5#include <string.h>
6#include <stdio.h>
6 7
7#include <SDL.h> 8#include <SDL.h>
8#include <SDL_image.h> 9#include <SDL_image.h>
9#include <SDL_opengl.h> 10#include <SDL_opengl.h>
10 11
11#include <pango/pango.h> 12#include <pango/pango.h>
12#include <pango/pangofc-fontmap.h> 13#include <pango/pangofc-fontmap.h>
13#include <pango/pangoft2.h> 14#include <pango/pangoft2.h>
14
15#include <sys/time.h>
16#include <sys/types.h>
17#include <unistd.h>
18 15
19#include <sys/types.h> 16#include <sys/types.h>
20#include <sys/socket.h> 17#include <sys/socket.h>
21#include <netinet/in.h> 18#include <netinet/in.h>
22#include <netinet/tcp.h> 19#include <netinet/tcp.h>
20
21#include <inttypes.h>
23 22
24static PangoContext *context; 23static PangoContext *context;
25static PangoFontMap *fontmap; 24static PangoFontMap *fontmap;
26 25
27typedef struct cf_layout { 26typedef struct cf_layout {
55 54
56 *w = (*w + 3) & ~3; 55 *w = (*w + 3) & ~3;
57 if (!*w) *w = 1; 56 if (!*w) *w = 1;
58 if (!*h) *h = 1; 57 if (!*h) *h = 1;
59} 58}
59
60typedef struct {
61 uint16_t face[3];
62 uint8_t darkness;
63 uint8_t padding;
64} mapcell;
65
66typedef struct {
67 uint32_t cols;
68 mapcell *col;
69} maprow;
70
71typedef struct map {
72 int x, y, w, h;
73 int faces;
74 GLint *face;
75
76 uint32_t rows;
77 maprow *row;
78} *CFClient__Map;
60 79
61MODULE = CFClient PACKAGE = CFClient 80MODULE = CFClient PACKAGE = CFClient
62 81
63PROTOTYPES: ENABLE 82PROTOTYPES: ENABLE
64 83
149 PUSHs (sv_2mortal (newSViv (surface2->w))); 168 PUSHs (sv_2mortal (newSViv (surface2->w)));
150 PUSHs (sv_2mortal (newSViv (surface2->h))); 169 PUSHs (sv_2mortal (newSViv (surface2->h)));
151 SDL_LockSurface (surface2); 170 SDL_LockSurface (surface2);
152 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 171 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch)));
153 SDL_UnlockSurface (surface2); 172 SDL_UnlockSurface (surface2);
154 PUSHs (sv_2mortal (newSViv (surface->format->Amask ? GL_RGBA : GL_RGB))); 173 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
155 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 174 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
156 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV))); 175 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV)));
157 176
158 SDL_FreeSurface (surface); 177 SDL_FreeSurface (surface);
159 SDL_FreeSurface (surface2); 178 SDL_FreeSurface (surface2);
160} 179}
180
181void
182fatal (char *message)
183 CODE:
184#ifdef WIN32
185 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
186#else
187 fprintf (stderr, "%s\n", message);
188#endif
189 exit (1);
161 190
162MODULE = CFClient PACKAGE = CFClient::Layout 191MODULE = CFClient PACKAGE = CFClient::Layout
163 192
164CFClient::Layout 193CFClient::Layout
165new (SV *class, int base_height = 10) 194new (SV *class, int base_height = 10)
294 glTexCoord2d (0, t); glVertex2d (x , y + h); 323 glTexCoord2d (0, t); glVertex2d (x , y + h);
295 glTexCoord2d (s, t); glVertex2d (x + w, y + h); 324 glTexCoord2d (s, t); glVertex2d (x + w, y + h);
296 glTexCoord2d (s, 0); glVertex2d (x + w, y ); 325 glTexCoord2d (s, 0); glVertex2d (x + w, y );
297 glEnd (); 326 glEnd ();
298} 327}
328
329MODULE = CFClient PACKAGE = CFClient::Map
330
331CFClient::Map
332new (SV *class, int map_width, int map_height)
333 CODE:
334 New (0, RETVAL, 1, struct map);
335 RETVAL->x = 0;
336 RETVAL->y = 0;
337 RETVAL->w = map_width;
338 RETVAL->h = map_height;
339 RETVAL->faces = 0;
340 RETVAL->face = 0;
341
342 RETVAL->rows = 0;
343 RETVAL->row = 0;
344 OUTPUT:
345 RETVAL
346
347void
348DESTROY (CFClient::Map self)
349 CODE:
350{
351 int r, c;
352
353 Safefree (self->face);
354 for (r = 0; r < self->rows; r++)
355 {
356 maprow *row = self->row + r;
357 if (!row)
358 continue;
359
360 Safefree (row->col);
361 }
362
363 Safefree (self->row);
364 Safefree (self);
365}
366

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines