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.43 by root, Mon Apr 17 06:50:26 2006 UTC vs.
Revision 1.51 by root, Wed Apr 19 20:46:44 2006 UTC

1#ifdef _WIN32
2# include <malloc.h>
3#endif
4
1#include "EXTERN.h" 5#include "EXTERN.h"
2#include "perl.h" 6#include "perl.h"
3#include "XSUB.h" 7#include "XSUB.h"
4 8
5#include <string.h> 9#include <string.h>
13 17
14#include <pango/pango.h> 18#include <pango/pango.h>
15#include <pango/pangofc-fontmap.h> 19#include <pango/pangofc-fontmap.h>
16#include <pango/pangoft2.h> 20#include <pango/pangoft2.h>
17 21
22#ifndef _WIN32
18#include <sys/types.h> 23# include <sys/types.h>
19#include <sys/socket.h> 24# include <sys/socket.h>
20#include <netinet/in.h> 25# include <netinet/in.h>
21#include <netinet/tcp.h> 26# include <netinet/tcp.h>
22
23#include <inttypes.h> 27# include <inttypes.h>
28#else
29 typedef unsigned char uint8_t;
30 typedef unsigned short uint16_t;
31 typedef unsigned int uint32_t;
32 typedef signed char int8_t;
33 typedef signed short int16_t;
34 typedef signed int int32_t;
35#endif
24 36
25#define FOW_DARKNESS 32 37#define FOW_DARKNESS 32
26 38
27#define MAP_EXTEND_X 32 39#define MAP_EXTEND_X 32
28#define MAP_EXTEND_Y 512 40#define MAP_EXTEND_Y 512
47{ 59{
48 /* use a random scale factor to account for unknown descenders, 0.8 works 60 /* use a random scale factor to account for unknown descenders, 0.8 works
49 * reasonably well with bitstream vera 61 * reasonably well with bitstream vera
50 */ 62 */
51 PangoFontDescription *font = pango_context_get_font_description (context); 63 PangoFontDescription *font = pango_context_get_font_description (context);
52 pango_font_description_set_absolute_size (font, self->base_height * (PANGO_SCALE * 8 / 10)); 64
65 int height = self->base_height * (PANGO_SCALE * 8 / 10);
66
67 if (pango_font_description_get_size (font) != height)
68 {
69 pango_font_description_set_absolute_size (font, height);
70 pango_layout_context_changed (self->pl);
71 }
53} 72}
54 73
55static void 74static void
56layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 75layout_get_pixel_size (CFClient__Layout self, int *w, int *h)
57{ 76{
83 mapcell *col; 102 mapcell *col;
84} maprow; 103} maprow;
85 104
86typedef struct map { 105typedef struct map {
87 int x, y, w, h; 106 int x, y, w, h;
88 int dx, dy; /* delayed map scrolling */
89 int ox, oy; /* offset to virtual global coordinate system */ 107 int ox, oy; /* offset to virtual global coordinate system */
90 int faces; 108 int faces;
91 mapface *face; 109 mapface *face;
92 110
93 int texs; 111 int texs;
94 maptex *tex; 112 maptex *tex;
95 113
96 uint32_t rows; 114 int32_t rows;
97 maprow *row; 115 maprow *row;
98} *CFClient__Map; 116} *CFClient__Map;
99 117
100static char * 118static char *
101prepend (char *ptr, int sze, int inc) 119prepend (char *ptr, int sze, int inc)
196 214
197static void 215static void
198map_blank (CFClient__Map self, int x0, int y0, int w, int h) 216map_blank (CFClient__Map self, int x0, int y0, int w, int h)
199{ 217{
200 int x, y; 218 int x, y;
219 maprow *row;
201 220
202 for (y = y0; y < y0 + h; y++) 221 for (y = y0; y < y0 + h; y++)
203 if (y >= 0) 222 if (y >= 0)
204 { 223 {
205 if (y >= self->rows) 224 if (y >= self->rows)
206 break; 225 break;
207 226
208 maprow *row = self->row + y; 227 row = self->row + y;
209 228
210 for (x = x0; x < x0 + w; x++) 229 for (x = x0; x < x0 + w; x++)
211 if (x >= row->c0) 230 if (x >= row->c0)
212 { 231 {
213 if (x >= row->c1) 232 if (x >= row->c1)
222 241
223PROTOTYPES: ENABLE 242PROTOTYPES: ENABLE
224 243
225BOOT: 244BOOT:
226{ 245{
246 HV *stash = gv_stashpv ("CFClient", 1);
247 static const struct {
248 const char *name;
249 IV iv;
250 } *civ, const_iv[] = {
251# define const_iv(name) { # name, (IV)name }
252 const_iv (SDL_ACTIVEEVENT),
253 const_iv (SDL_KEYDOWN),
254 const_iv (SDL_KEYUP),
255 const_iv (SDL_MOUSEMOTION),
256 const_iv (SDL_MOUSEBUTTONDOWN),
257 const_iv (SDL_MOUSEBUTTONUP),
258 const_iv (SDL_JOYAXISMOTION),
259 const_iv (SDL_JOYBALLMOTION),
260 const_iv (SDL_JOYHATMOTION),
261 const_iv (SDL_JOYBUTTONDOWN),
262 const_iv (SDL_JOYBUTTONUP),
263 const_iv (SDL_QUIT),
264 const_iv (SDL_SYSWMEVENT),
265 const_iv (SDL_EVENT_RESERVEDA),
266 const_iv (SDL_EVENT_RESERVEDB),
267 const_iv (SDL_VIDEORESIZE),
268 const_iv (SDL_VIDEOEXPOSE),
269 const_iv (SDL_USEREVENT),
270 const_iv (SDLK_KP0),
271 const_iv (SDLK_KP1),
272 const_iv (SDLK_KP2),
273 const_iv (SDLK_KP3),
274 const_iv (SDLK_KP4),
275 const_iv (SDLK_KP5),
276 const_iv (SDLK_KP6),
277 const_iv (SDLK_KP7),
278 const_iv (SDLK_KP8),
279 const_iv (SDLK_KP9),
280 const_iv (SDLK_KP_PERIOD),
281 const_iv (SDLK_KP_DIVIDE),
282 const_iv (SDLK_KP_MULTIPLY),
283 const_iv (SDLK_KP_MINUS),
284 const_iv (SDLK_KP_PLUS),
285 const_iv (SDLK_KP_ENTER),
286 const_iv (SDLK_KP_EQUALS),
287 const_iv (SDLK_UP),
288 const_iv (SDLK_DOWN),
289 const_iv (SDLK_RIGHT),
290 const_iv (SDLK_LEFT),
291 const_iv (SDLK_INSERT),
292 const_iv (SDLK_HOME),
293 const_iv (SDLK_END),
294 const_iv (SDLK_PAGEUP),
295 const_iv (SDLK_PAGEDOWN),
296 const_iv (SDLK_F1),
297 const_iv (SDLK_F2),
298 const_iv (SDLK_F3),
299 const_iv (SDLK_F4),
300 const_iv (SDLK_F5),
301 const_iv (SDLK_F6),
302 const_iv (SDLK_F7),
303 const_iv (SDLK_F8),
304 const_iv (SDLK_F9),
305 const_iv (SDLK_F10),
306 const_iv (SDLK_F11),
307 const_iv (SDLK_F12),
308 const_iv (SDLK_F13),
309 const_iv (SDLK_F14),
310 const_iv (SDLK_F15),
311 const_iv (SDLK_NUMLOCK),
312 const_iv (SDLK_CAPSLOCK),
313 const_iv (SDLK_SCROLLOCK),
314 const_iv (SDLK_RSHIFT),
315 const_iv (SDLK_LSHIFT),
316 const_iv (SDLK_RCTRL),
317 const_iv (SDLK_LCTRL),
318 const_iv (SDLK_RALT),
319 const_iv (SDLK_LALT),
320 const_iv (SDLK_RMETA),
321 const_iv (SDLK_LMETA),
322 const_iv (SDLK_LSUPER),
323 const_iv (SDLK_RSUPER),
324 const_iv (SDLK_MODE),
325 const_iv (SDLK_COMPOSE),
326 const_iv (SDLK_HELP),
327 const_iv (SDLK_PRINT),
328 const_iv (SDLK_SYSREQ),
329 const_iv (SDLK_BREAK),
330 const_iv (SDLK_MENU),
331 const_iv (SDLK_POWER),
332 const_iv (SDLK_EURO),
333 const_iv (SDLK_UNDO),
334 const_iv (KMOD_NONE),
335 const_iv (KMOD_LSHIFT),
336 const_iv (KMOD_RSHIFT),
337 const_iv (KMOD_LCTRL),
338 const_iv (KMOD_RCTRL),
339 const_iv (KMOD_LALT),
340 const_iv (KMOD_RALT),
341 const_iv (KMOD_LMETA),
342 const_iv (KMOD_RMETA),
343 const_iv (KMOD_NUM),
344 const_iv (KMOD_CAPS),
345 const_iv (KMOD_MODE),
346 const_iv (KMOD_CTRL),
347 const_iv (KMOD_SHIFT),
348 const_iv (KMOD_ALT),
349 const_iv (KMOD_META)
350# undef const_iv
351 };
352
353 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
354 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
355
227 fontmap = pango_ft2_font_map_new (); 356 fontmap = pango_ft2_font_map_new ();
228 pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)fontmap, substitute_func, 0, 0); 357 pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)fontmap, substitute_func, 0, 0);
229 context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); 358 context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap);
230} 359}
360
361int
362SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO)
363
364void
365SDL_Quit ()
366
367void
368SDL_ListModes ()
369 PPCODE:
370{
371 SDL_Rect **m;
372
373 SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5);
374 SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 5);
375 SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5);
376 SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 1);
377
378 SDL_GL_SetAttribute (SDL_GL_ACCUM_RED_SIZE, 0);
379 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
380 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
381 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
382
383 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
384 SDL_GL_SetAttribute (SDL_GL_BUFFER_SIZE, 15);
385 SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 0);
386
387 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
388
389 if (m && m != (SDL_Rect **)-1)
390 while (*m)
391 {
392 AV *av = newAV ();
393 av_push (av, newSViv ((*m)->w));
394 av_push (av, newSViv ((*m)->h));
395 XPUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
396
397 ++m;
398 }
399}
400
401int
402SDL_SetVideoMode (int w, int h, int fullscreen)
403 CODE:
404 RETVAL = !!SDL_SetVideoMode (
405 w, h, 0, SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0)
406 );
407 SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+");
408 OUTPUT:
409 RETVAL
231 410
232void 411void
233lowdelay (int fd, int val = 1) 412lowdelay (int fd, int val = 1)
234 CODE: 413 CODE:
414#ifndef _WIN32
235 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); 415 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val));
416#endif
236 417
237char * 418char *
238gl_version () 419gl_version ()
239 CODE: 420 CODE:
240 RETVAL = (char *)glGetString (GL_VERSION); 421 RETVAL = (char *)glGetString (GL_VERSION);
286 croak ("load_image: %s", SDL_GetError ()); 467 croak ("load_image: %s", SDL_GetError ());
287 468
288 fmt.palette = NULL; 469 fmt.palette = NULL;
289 fmt.BitsPerPixel = 32; 470 fmt.BitsPerPixel = 32;
290 fmt.BytesPerPixel = 4; 471 fmt.BytesPerPixel = 4;
472#if SDL_BYTEORDER == SDL_LIL_ENDIAN
291 fmt.Rmask = 0x000000ff; 473 fmt.Rmask = 0x000000ff;
292 fmt.Gmask = 0x0000ff00; 474 fmt.Gmask = 0x0000ff00;
293 fmt.Bmask = 0x00ff0000; 475 fmt.Bmask = 0x00ff0000;
294 fmt.Amask = 0xff000000; 476 fmt.Amask = 0xff000000;
477#else
478 fmt.Rmask = 0xff000000;
479 fmt.Gmask = 0x00ff0000;
480 fmt.Bmask = 0x0000ff00;
481 fmt.Amask = 0x000000ff;
482#endif
295 fmt.Rloss = 0; 483 fmt.Rloss = 0;
296 fmt.Gloss = 0; 484 fmt.Gloss = 0;
297 fmt.Bloss = 0; 485 fmt.Bloss = 0;
298 fmt.Aloss = 0; 486 fmt.Aloss = 0;
299 fmt.Rshift = 0; 487 fmt.Rshift = 0;
313 SDL_LockSurface (surface2); 501 SDL_LockSurface (surface2);
314 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 502 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch)));
315 SDL_UnlockSurface (surface2); 503 SDL_UnlockSurface (surface2);
316 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); 504 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
317 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 505 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
318 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV))); 506 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
319 507
320 SDL_FreeSurface (surface); 508 SDL_FreeSurface (surface);
321 SDL_FreeSurface (surface2); 509 SDL_FreeSurface (surface2);
322} 510}
323 511
347} 535}
348 536
349void 537void
350fatal (char *message) 538fatal (char *message)
351 CODE: 539 CODE:
352#ifdef WIN32 540#ifdef _WIN32
353 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); 541 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
354#else 542#else
355 fprintf (stderr, "FATAL: %s\n", message); 543 fprintf (stderr, "FATAL: %s\n", message);
356#endif 544#endif
357 exit (1); 545 exit (1);
391 STRLEN textlen; 579 STRLEN textlen;
392 char *text = SvPVutf8 (text_, textlen); 580 char *text = SvPVutf8 (text_, textlen);
393 581
394 pango_layout_set_markup (self->pl, text, textlen); 582 pango_layout_set_markup (self->pl, text, textlen);
395} 583}
584
585SV *
586get_text (CFClient::Layout self)
587 CODE:
588 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
589 SvUTF8_on (RETVAL);
590 OUTPUT:
591 RETVAL
396 592
397void 593void
398set_height (CFClient::Layout self, int base_height) 594set_height (CFClient::Layout self, int base_height)
399 CODE: 595 CODE:
400 self->base_height = base_height; 596 self->base_height = base_height;
566 { 762 {
567 Append (maptex, self->tex, self->texs, self->texs); 763 Append (maptex, self->tex, self->texs, self->texs);
568 self->texs *= 2; 764 self->texs *= 2;
569 } 765 }
570 766
767 {
571 maptex *tex = self->tex + texid; 768 maptex *tex = self->tex + texid;
572 769
573 tex->name = name; 770 tex->name = name;
574 tex->w = w; 771 tex->w = w;
575 tex->h = h; 772 tex->h = h;
576 tex->s = s; 773 tex->s = s;
577 tex->t = t; 774 tex->t = t;
578 tex->r = r; 775 tex->r = r;
579 tex->g = g; 776 tex->g = g;
580 tex->b = b; 777 tex->b = b;
581 tex->a = a; 778 tex->a = a;
779 }
582} 780}
583 781
584int 782int
585ox (CFClient::Map self) 783ox (CFClient::Map self)
586 ALIAS: 784 ALIAS:
596 794
597void 795void
598scroll (CFClient::Map self, int dx, int dy) 796scroll (CFClient::Map self, int dx, int dy)
599 CODE: 797 CODE:
600{ 798{
601 self->dx += dx; self->ox += dx;
602 self->dy += dy; self->oy += dy;
603}
604
605void
606map1a_update (CFClient::Map self, SV *data_)
607 CODE:
608{
609 if (self->dx > 0) 799 if (dx > 0)
610 map_blank (self, self->x, self->y, self->dx - 1, self->h); 800 map_blank (self, self->x, self->y, dx - 1, self->h);
611 else if (self->dx < 0) 801 else if (dx < 0)
612 map_blank (self, self->x + self->w + self->dx + 1, self->y, 1 - self->dx, self->h); 802 map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h);
613 803
614 if (self->dy > 0) 804 if (dy > 0)
615 map_blank (self, self->x, self->y, self->w, self->dy - 1); 805 map_blank (self, self->x, self->y, self->w, dy - 1);
616 else if (self->dy < 0) 806 else if (dy < 0)
617 map_blank (self, self->x, self->y + self->h + self->dy + 1, self->w, 1 - self->dy); 807 map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy);
618 808
619 self->x += self->dx; self->dx = 0; 809 self->ox += dx; self->x += dx;
620 self->y += self->dy; self->dy = 0; 810 self->oy += dy; self->y += dy;
621 811
622 while (self->y < 0) 812 while (self->y < 0)
623 { 813 {
624 Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); 814 Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y);
625 815
626 self->rows += MAP_EXTEND_Y; 816 self->rows += MAP_EXTEND_Y;
627 self->y += MAP_EXTEND_Y; 817 self->y += MAP_EXTEND_Y;
628 } 818 }
819}
629 820
821void
822map1a_update (CFClient::Map self, SV *data_)
823 CODE:
824{
630 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 825 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
631 uint8_t *data_end = (uint8_t *)SvEND (data_); 826 uint8_t *data_end = (uint8_t *)SvEND (data_);
827 mapcell *cell;
828 int x, y, flags;
632 829
633 while (data < data_end) 830 while (data < data_end)
634 { 831 {
635 int flags = (data [0] << 8) + data [1]; data += 2; 832 flags = (data [0] << 8) + data [1]; data += 2;
636 833
637 int x = ((flags >> 10) & 63) + self->x; 834 x = ((flags >> 10) & 63) + self->x;
638 int y = ((flags >> 4) & 63) + self->y; 835 y = ((flags >> 4) & 63) + self->y;
639 836
640 mapcell *cell = map_get_cell (self, x, y); 837 cell = map_get_cell (self, x, y);
641 838
642 if (flags & 15) 839 if (flags & 15)
643 { 840 {
644 if (cell->darkness < 0) // && x < self->w && y < self->h) 841 if (cell->darkness < 0)
645 { 842 {
646 cell->darkness = 0; 843 cell->darkness = 0;
647 cell->face [0] = 0; 844 cell->face [0] = 0;
648 cell->face [1] = 0; 845 cell->face [1] = 0;
649 cell->face [2] = 0; 846 cell->face [2] = 0;
650 } 847 }
651 848
652 cell->darkness = flags & 8 ? *data++ : 255; 849 cell->darkness = flags & 8 ? *data++ : 255;
653 850
654 //TODO: don't trust server data to be in-range(!) 851 //TODO: don't trust server data to be in-range(!)
655 852
656 if (flags & 4) 853 if (flags & 4)
735 932
736void 933void
737draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 934draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
738 PPCODE: 935 PPCODE:
739{ 936{
937 int vx, vy;
938 int x, y, z;
939 int last_name;
940 mapface face;
740 int sw4 = (sw + 3) & ~3; 941 int sw4 = (sw + 3) & ~3;
741 SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); 942 SV *darkness_sv = sv_2mortal (newSV (sw4 * sh));
742 uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); 943 uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv);
944
743 memset (darkness, 255, sw4 * sh); 945 memset (darkness, 255, sw4 * sh);
744 SvPOK_only (darkness_sv); 946 SvPOK_only (darkness_sv);
745 SvCUR_set (darkness_sv, sw4 * sh); 947 SvCUR_set (darkness_sv, sw4 * sh);
746 948
747 int vx = self->x + (self->w - sw) / 2 - shift_x; 949 vx = self->x + (self->w - sw) / 2 - shift_x;
748 int vy = self->y + (self->h - sh) / 2 - shift_y; 950 vy = self->y + (self->h - sh) / 2 - shift_y;
749 951
750 /* 952 /*
751 int vx = self->vx = self->w >= sw 953 int vx = self->vx = self->w >= sw
752 ? self->x + (self->w - sw) / 2 954 ? self->x + (self->w - sw) / 2
753 : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx)); 955 : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx));
762 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 964 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
763 glEnable (GL_BLEND); 965 glEnable (GL_BLEND);
764 glEnable (GL_TEXTURE_2D); 966 glEnable (GL_TEXTURE_2D);
765 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 967 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
766 968
767 int x, y, z;
768
769 int last_name = 0;
770
771 glBegin (GL_QUADS); 969 glBegin (GL_QUADS);
970
971 last_name = 0;
772 972
773 for (z = 0; z < 3; z++) 973 for (z = 0; z < 3; z++)
774 for (y = 0; y < sh; y++) 974 for (y = 0; y < sh; y++)
775 if (0 <= y + vy && y + vy < self->rows) 975 if (0 <= y + vy && y + vy < self->rows)
776 { 976 {
783 983
784 darkness[y * sw4 + x] = cell->darkness < 0 984 darkness[y * sw4 + x] = cell->darkness < 0
785 ? 255 - FOW_DARKNESS 985 ? 255 - FOW_DARKNESS
786 : 255 - cell->darkness; 986 : 255 - cell->darkness;
787 987
788 mapface face = cell->face [z]; 988 face = cell->face [z];
789 989
790 if (face) 990 if (face)
791 { 991 {
792 maptex tex = self->tex [face]; 992 maptex tex = self->tex [face];
793 993
853 for (x = x0; x < x1; x++) 1053 for (x = x0; x < x1; x++)
854 { 1054 {
855 if (row && row->c0 <= x && x < row->c1) 1055 if (row && row->c0 <= x && x < row->c1)
856 { 1056 {
857 mapcell *cell = row->col + (x - row->c0); 1057 mapcell *cell = row->col + (x - row->c0);
858
859 uint8_t flags = 0; 1058 uint8_t flags = 0;
860 1059
861 if (cell->face [0]) flags |= 1; 1060 if (cell->face [0]) flags |= 1;
862 if (cell->face [1]) flags |= 2; 1061 if (cell->face [1]) flags |= 2;
863 if (cell->face [2]) flags |= 4; 1062 if (cell->face [2]) flags |= 4;
897void 1096void
898set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1097set_rect (CFClient::Map self, int x0, int y0, uint8_t *data)
899 PPCODE: 1098 PPCODE:
900{ 1099{
901 int x, y, z; 1100 int x, y, z;
1101 int w, h;
902 int x1, y1; 1102 int x1, y1;
903 1103
904 if (*data++ != 0) 1104 if (*data++ != 0)
905 return; /* version mismatch */ 1105 return; /* version mismatch */
906 1106
907 int w = *data++ << 8; w |= *data++; 1107 w = *data++ << 8; w |= *data++;
908 int h = *data++ << 8; h |= *data++; 1108 h = *data++ << 8; h |= *data++;
909 1109
910 // we need to do this 'cause we don't keep an absolute coord system for rows 1110 // we need to do this 'cause we don't keep an absolute coord system for rows
911 // TODO: treat rows as we treat 1111 // TODO: treat rows as we treat
912 map_get_row (self, y0 + self->y - self->oy);//D 1112 map_get_row (self, y0 + self->y - self->oy);//D
913 map_get_row (self, y0 + self->y - self->oy + h - 1);//D 1113 map_get_row (self, y0 + self->y - self->oy + h - 1);//D

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines