|
|
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 | |
55 | static void |
74 | static void |
56 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
75 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
57 | { |
76 | { |
… | |
… | |
90 | mapface *face; |
109 | mapface *face; |
91 | |
110 | |
92 | int texs; |
111 | int texs; |
93 | maptex *tex; |
112 | maptex *tex; |
94 | |
113 | |
95 | uint32_t rows; |
114 | int32_t rows; |
96 | maprow *row; |
115 | maprow *row; |
97 | } *CFClient__Map; |
116 | } *CFClient__Map; |
98 | |
117 | |
99 | static char * |
118 | static char * |
100 | prepend (char *ptr, int sze, int inc) |
119 | prepend (char *ptr, int sze, int inc) |
… | |
… | |
195 | |
214 | |
196 | static void |
215 | static void |
197 | map_blank (CFClient__Map self, int x0, int y0, int w, int h) |
216 | map_blank (CFClient__Map self, int x0, int y0, int w, int h) |
198 | { |
217 | { |
199 | int x, y; |
218 | int x, y; |
|
|
219 | maprow *row; |
200 | |
220 | |
201 | for (y = y0; y < y0 + h; y++) |
221 | for (y = y0; y < y0 + h; y++) |
202 | if (y >= 0) |
222 | if (y >= 0) |
203 | { |
223 | { |
204 | if (y >= self->rows) |
224 | if (y >= self->rows) |
205 | break; |
225 | break; |
206 | |
226 | |
207 | maprow *row = self->row + y; |
227 | row = self->row + y; |
208 | |
228 | |
209 | for (x = x0; x < x0 + w; x++) |
229 | for (x = x0; x < x0 + w; x++) |
210 | if (x >= row->c0) |
230 | if (x >= row->c0) |
211 | { |
231 | { |
212 | if (x >= row->c1) |
232 | if (x >= row->c1) |
… | |
… | |
221 | |
241 | |
222 | PROTOTYPES: ENABLE |
242 | PROTOTYPES: ENABLE |
223 | |
243 | |
224 | BOOT: |
244 | BOOT: |
225 | { |
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 | |
226 | fontmap = pango_ft2_font_map_new (); |
356 | fontmap = pango_ft2_font_map_new (); |
227 | 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); |
228 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
358 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
229 | } |
359 | } |
|
|
360 | |
|
|
361 | int |
|
|
362 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO) |
|
|
363 | |
|
|
364 | void |
|
|
365 | SDL_Quit () |
|
|
366 | |
|
|
367 | void |
|
|
368 | SDL_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 | |
|
|
401 | int |
|
|
402 | SDL_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 |
230 | |
410 | |
231 | void |
411 | void |
232 | lowdelay (int fd, int val = 1) |
412 | lowdelay (int fd, int val = 1) |
233 | CODE: |
413 | CODE: |
|
|
414 | #ifndef _WIN32 |
234 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
415 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
|
|
416 | #endif |
235 | |
417 | |
236 | char * |
418 | char * |
237 | gl_version () |
419 | gl_version () |
238 | CODE: |
420 | CODE: |
239 | RETVAL = (char *)glGetString (GL_VERSION); |
421 | RETVAL = (char *)glGetString (GL_VERSION); |
… | |
… | |
285 | croak ("load_image: %s", SDL_GetError ()); |
467 | croak ("load_image: %s", SDL_GetError ()); |
286 | |
468 | |
287 | fmt.palette = NULL; |
469 | fmt.palette = NULL; |
288 | fmt.BitsPerPixel = 32; |
470 | fmt.BitsPerPixel = 32; |
289 | fmt.BytesPerPixel = 4; |
471 | fmt.BytesPerPixel = 4; |
|
|
472 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN |
290 | fmt.Rmask = 0x000000ff; |
473 | fmt.Rmask = 0x000000ff; |
291 | fmt.Gmask = 0x0000ff00; |
474 | fmt.Gmask = 0x0000ff00; |
292 | fmt.Bmask = 0x00ff0000; |
475 | fmt.Bmask = 0x00ff0000; |
293 | 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 |
294 | fmt.Rloss = 0; |
483 | fmt.Rloss = 0; |
295 | fmt.Gloss = 0; |
484 | fmt.Gloss = 0; |
296 | fmt.Bloss = 0; |
485 | fmt.Bloss = 0; |
297 | fmt.Aloss = 0; |
486 | fmt.Aloss = 0; |
298 | fmt.Rshift = 0; |
487 | fmt.Rshift = 0; |
… | |
… | |
312 | SDL_LockSurface (surface2); |
501 | SDL_LockSurface (surface2); |
313 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
502 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
314 | SDL_UnlockSurface (surface2); |
503 | SDL_UnlockSurface (surface2); |
315 | 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))); |
316 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
505 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
317 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV))); |
506 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
318 | |
507 | |
319 | SDL_FreeSurface (surface); |
508 | SDL_FreeSurface (surface); |
320 | SDL_FreeSurface (surface2); |
509 | SDL_FreeSurface (surface2); |
321 | } |
510 | } |
322 | |
511 | |
… | |
… | |
346 | } |
535 | } |
347 | |
536 | |
348 | void |
537 | void |
349 | fatal (char *message) |
538 | fatal (char *message) |
350 | CODE: |
539 | CODE: |
351 | #ifdef WIN32 |
540 | #ifdef _WIN32 |
352 | 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); |
353 | #else |
542 | #else |
354 | fprintf (stderr, "FATAL: %s\n", message); |
543 | fprintf (stderr, "FATAL: %s\n", message); |
355 | #endif |
544 | #endif |
356 | exit (1); |
545 | exit (1); |
… | |
… | |
390 | STRLEN textlen; |
579 | STRLEN textlen; |
391 | char *text = SvPVutf8 (text_, textlen); |
580 | char *text = SvPVutf8 (text_, textlen); |
392 | |
581 | |
393 | pango_layout_set_markup (self->pl, text, textlen); |
582 | pango_layout_set_markup (self->pl, text, textlen); |
394 | } |
583 | } |
|
|
584 | |
|
|
585 | SV * |
|
|
586 | get_text (CFClient::Layout self) |
|
|
587 | CODE: |
|
|
588 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
|
|
589 | SvUTF8_on (RETVAL); |
|
|
590 | OUTPUT: |
|
|
591 | RETVAL |
395 | |
592 | |
396 | void |
593 | void |
397 | set_height (CFClient::Layout self, int base_height) |
594 | set_height (CFClient::Layout self, int base_height) |
398 | CODE: |
595 | CODE: |
399 | self->base_height = base_height; |
596 | self->base_height = base_height; |
… | |
… | |
565 | { |
762 | { |
566 | Append (maptex, self->tex, self->texs, self->texs); |
763 | Append (maptex, self->tex, self->texs, self->texs); |
567 | self->texs *= 2; |
764 | self->texs *= 2; |
568 | } |
765 | } |
569 | |
766 | |
|
|
767 | { |
570 | maptex *tex = self->tex + texid; |
768 | maptex *tex = self->tex + texid; |
571 | |
769 | |
572 | tex->name = name; |
770 | tex->name = name; |
573 | tex->w = w; |
771 | tex->w = w; |
574 | tex->h = h; |
772 | tex->h = h; |
575 | tex->s = s; |
773 | tex->s = s; |
576 | tex->t = t; |
774 | tex->t = t; |
577 | tex->r = r; |
775 | tex->r = r; |
578 | tex->g = g; |
776 | tex->g = g; |
579 | tex->b = b; |
777 | tex->b = b; |
580 | tex->a = a; |
778 | tex->a = a; |
|
|
779 | } |
581 | } |
780 | } |
582 | |
781 | |
583 | int |
782 | int |
584 | ox (CFClient::Map self) |
783 | ox (CFClient::Map self) |
585 | ALIAS: |
784 | ALIAS: |
… | |
… | |
623 | map1a_update (CFClient::Map self, SV *data_) |
822 | map1a_update (CFClient::Map self, SV *data_) |
624 | CODE: |
823 | CODE: |
625 | { |
824 | { |
626 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
825 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
627 | 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; |
628 | |
829 | |
629 | while (data < data_end) |
830 | while (data < data_end) |
630 | { |
831 | { |
631 | int flags = (data [0] << 8) + data [1]; data += 2; |
832 | flags = (data [0] << 8) + data [1]; data += 2; |
632 | |
833 | |
633 | int x = ((flags >> 10) & 63) + self->x; |
834 | x = ((flags >> 10) & 63) + self->x; |
634 | int y = ((flags >> 4) & 63) + self->y; |
835 | y = ((flags >> 4) & 63) + self->y; |
635 | |
836 | |
636 | mapcell *cell = map_get_cell (self, x, y); |
837 | cell = map_get_cell (self, x, y); |
637 | |
838 | |
638 | if (flags & 15) |
839 | if (flags & 15) |
639 | { |
840 | { |
640 | if (cell->darkness < 0) |
841 | if (cell->darkness < 0) |
641 | { |
842 | { |
… | |
… | |
731 | |
932 | |
732 | void |
933 | void |
733 | draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
934 | draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
734 | PPCODE: |
935 | PPCODE: |
735 | { |
936 | { |
|
|
937 | int vx, vy; |
|
|
938 | int x, y, z; |
|
|
939 | int last_name; |
|
|
940 | mapface face; |
736 | int sw4 = (sw + 3) & ~3; |
941 | int sw4 = (sw + 3) & ~3; |
737 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
942 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
738 | uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); |
943 | uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); |
|
|
944 | |
739 | memset (darkness, 255, sw4 * sh); |
945 | memset (darkness, 255, sw4 * sh); |
740 | SvPOK_only (darkness_sv); |
946 | SvPOK_only (darkness_sv); |
741 | SvCUR_set (darkness_sv, sw4 * sh); |
947 | SvCUR_set (darkness_sv, sw4 * sh); |
742 | |
948 | |
743 | int vx = self->x + (self->w - sw) / 2 - shift_x; |
949 | vx = self->x + (self->w - sw) / 2 - shift_x; |
744 | int vy = self->y + (self->h - sh) / 2 - shift_y; |
950 | vy = self->y + (self->h - sh) / 2 - shift_y; |
745 | |
951 | |
746 | /* |
952 | /* |
747 | int vx = self->vx = self->w >= sw |
953 | int vx = self->vx = self->w >= sw |
748 | ? self->x + (self->w - sw) / 2 |
954 | ? self->x + (self->w - sw) / 2 |
749 | : 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)); |
… | |
… | |
758 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
964 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
759 | glEnable (GL_BLEND); |
965 | glEnable (GL_BLEND); |
760 | glEnable (GL_TEXTURE_2D); |
966 | glEnable (GL_TEXTURE_2D); |
761 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
967 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
762 | |
968 | |
763 | int x, y, z; |
|
|
764 | |
|
|
765 | int last_name = 0; |
|
|
766 | |
|
|
767 | glBegin (GL_QUADS); |
969 | glBegin (GL_QUADS); |
|
|
970 | |
|
|
971 | last_name = 0; |
768 | |
972 | |
769 | for (z = 0; z < 3; z++) |
973 | for (z = 0; z < 3; z++) |
770 | for (y = 0; y < sh; y++) |
974 | for (y = 0; y < sh; y++) |
771 | if (0 <= y + vy && y + vy < self->rows) |
975 | if (0 <= y + vy && y + vy < self->rows) |
772 | { |
976 | { |
… | |
… | |
779 | |
983 | |
780 | darkness[y * sw4 + x] = cell->darkness < 0 |
984 | darkness[y * sw4 + x] = cell->darkness < 0 |
781 | ? 255 - FOW_DARKNESS |
985 | ? 255 - FOW_DARKNESS |
782 | : 255 - cell->darkness; |
986 | : 255 - cell->darkness; |
783 | |
987 | |
784 | mapface face = cell->face [z]; |
988 | face = cell->face [z]; |
785 | |
989 | |
786 | if (face) |
990 | if (face) |
787 | { |
991 | { |
788 | maptex tex = self->tex [face]; |
992 | maptex tex = self->tex [face]; |
789 | |
993 | |
… | |
… | |
849 | for (x = x0; x < x1; x++) |
1053 | for (x = x0; x < x1; x++) |
850 | { |
1054 | { |
851 | if (row && row->c0 <= x && x < row->c1) |
1055 | if (row && row->c0 <= x && x < row->c1) |
852 | { |
1056 | { |
853 | mapcell *cell = row->col + (x - row->c0); |
1057 | mapcell *cell = row->col + (x - row->c0); |
854 | |
|
|
855 | uint8_t flags = 0; |
1058 | uint8_t flags = 0; |
856 | |
1059 | |
857 | if (cell->face [0]) flags |= 1; |
1060 | if (cell->face [0]) flags |= 1; |
858 | if (cell->face [1]) flags |= 2; |
1061 | if (cell->face [1]) flags |= 2; |
859 | if (cell->face [2]) flags |= 4; |
1062 | if (cell->face [2]) flags |= 4; |
… | |
… | |
893 | void |
1096 | void |
894 | set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) |
1097 | set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) |
895 | PPCODE: |
1098 | PPCODE: |
896 | { |
1099 | { |
897 | int x, y, z; |
1100 | int x, y, z; |
|
|
1101 | int w, h; |
898 | int x1, y1; |
1102 | int x1, y1; |
899 | |
1103 | |
900 | if (*data++ != 0) |
1104 | if (*data++ != 0) |
901 | return; /* version mismatch */ |
1105 | return; /* version mismatch */ |
902 | |
1106 | |
903 | int w = *data++ << 8; w |= *data++; |
1107 | w = *data++ << 8; w |= *data++; |
904 | int h = *data++ << 8; h |= *data++; |
1108 | h = *data++ << 8; h |= *data++; |
905 | |
1109 | |
906 | // 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 |
907 | // TODO: treat rows as we treat |
1111 | // TODO: treat rows as we treat |
908 | map_get_row (self, y0 + self->y - self->oy);//D |
1112 | map_get_row (self, y0 + self->y - self->oy);//D |
909 | 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 |