|
|
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 |
… | |
… | |
97 | mapface *face; |
109 | mapface *face; |
98 | |
110 | |
99 | int texs; |
111 | int texs; |
100 | maptex *tex; |
112 | maptex *tex; |
101 | |
113 | |
102 | uint32_t rows; |
114 | int32_t rows; |
103 | maprow *row; |
115 | maprow *row; |
104 | } *CFClient__Map; |
116 | } *CFClient__Map; |
105 | |
117 | |
106 | static char * |
118 | static char * |
107 | prepend (char *ptr, int sze, int inc) |
119 | prepend (char *ptr, int sze, int inc) |
… | |
… | |
202 | |
214 | |
203 | static void |
215 | static void |
204 | 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) |
205 | { |
217 | { |
206 | int x, y; |
218 | int x, y; |
|
|
219 | maprow *row; |
207 | |
220 | |
208 | for (y = y0; y < y0 + h; y++) |
221 | for (y = y0; y < y0 + h; y++) |
209 | if (y >= 0) |
222 | if (y >= 0) |
210 | { |
223 | { |
211 | if (y >= self->rows) |
224 | if (y >= self->rows) |
212 | break; |
225 | break; |
213 | |
226 | |
214 | maprow *row = self->row + y; |
227 | row = self->row + y; |
215 | |
228 | |
216 | for (x = x0; x < x0 + w; x++) |
229 | for (x = x0; x < x0 + w; x++) |
217 | if (x >= row->c0) |
230 | if (x >= row->c0) |
218 | { |
231 | { |
219 | if (x >= row->c1) |
232 | if (x >= row->c1) |
… | |
… | |
228 | |
241 | |
229 | PROTOTYPES: ENABLE |
242 | PROTOTYPES: ENABLE |
230 | |
243 | |
231 | BOOT: |
244 | BOOT: |
232 | { |
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 | |
233 | fontmap = pango_ft2_font_map_new (); |
356 | fontmap = pango_ft2_font_map_new (); |
234 | 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); |
235 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
358 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
236 | } |
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 |
237 | |
410 | |
238 | void |
411 | void |
239 | lowdelay (int fd, int val = 1) |
412 | lowdelay (int fd, int val = 1) |
240 | CODE: |
413 | CODE: |
|
|
414 | #ifndef _WIN32 |
241 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
415 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
|
|
416 | #endif |
242 | |
417 | |
243 | char * |
418 | char * |
244 | gl_version () |
419 | gl_version () |
245 | CODE: |
420 | CODE: |
246 | RETVAL = (char *)glGetString (GL_VERSION); |
421 | RETVAL = (char *)glGetString (GL_VERSION); |
… | |
… | |
292 | croak ("load_image: %s", SDL_GetError ()); |
467 | croak ("load_image: %s", SDL_GetError ()); |
293 | |
468 | |
294 | fmt.palette = NULL; |
469 | fmt.palette = NULL; |
295 | fmt.BitsPerPixel = 32; |
470 | fmt.BitsPerPixel = 32; |
296 | fmt.BytesPerPixel = 4; |
471 | fmt.BytesPerPixel = 4; |
|
|
472 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN |
297 | fmt.Rmask = 0x000000ff; |
473 | fmt.Rmask = 0x000000ff; |
298 | fmt.Gmask = 0x0000ff00; |
474 | fmt.Gmask = 0x0000ff00; |
299 | fmt.Bmask = 0x00ff0000; |
475 | fmt.Bmask = 0x00ff0000; |
300 | 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 |
301 | fmt.Rloss = 0; |
483 | fmt.Rloss = 0; |
302 | fmt.Gloss = 0; |
484 | fmt.Gloss = 0; |
303 | fmt.Bloss = 0; |
485 | fmt.Bloss = 0; |
304 | fmt.Aloss = 0; |
486 | fmt.Aloss = 0; |
305 | fmt.Rshift = 0; |
487 | fmt.Rshift = 0; |
… | |
… | |
319 | SDL_LockSurface (surface2); |
501 | SDL_LockSurface (surface2); |
320 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
502 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
321 | SDL_UnlockSurface (surface2); |
503 | SDL_UnlockSurface (surface2); |
322 | 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))); |
323 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
505 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
324 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV))); |
506 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
325 | |
507 | |
326 | SDL_FreeSurface (surface); |
508 | SDL_FreeSurface (surface); |
327 | SDL_FreeSurface (surface2); |
509 | SDL_FreeSurface (surface2); |
328 | } |
510 | } |
329 | |
511 | |
… | |
… | |
353 | } |
535 | } |
354 | |
536 | |
355 | void |
537 | void |
356 | fatal (char *message) |
538 | fatal (char *message) |
357 | CODE: |
539 | CODE: |
358 | #ifdef WIN32 |
540 | #ifdef _WIN32 |
359 | 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); |
360 | #else |
542 | #else |
361 | fprintf (stderr, "FATAL: %s\n", message); |
543 | fprintf (stderr, "FATAL: %s\n", message); |
362 | #endif |
544 | #endif |
363 | exit (1); |
545 | exit (1); |
… | |
… | |
401 | } |
583 | } |
402 | |
584 | |
403 | SV * |
585 | SV * |
404 | get_text (CFClient::Layout self) |
586 | get_text (CFClient::Layout self) |
405 | CODE: |
587 | CODE: |
406 | RETVAL = newSVpv (pango_layout_get_text (self), 0); |
588 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
407 | SvUTF8_on (RETVAL); |
589 | SvUTF8_on (RETVAL); |
408 | OUTPUT: |
590 | OUTPUT: |
409 | RETVAL |
591 | RETVAL |
410 | |
592 | |
411 | void |
593 | void |
… | |
… | |
580 | { |
762 | { |
581 | Append (maptex, self->tex, self->texs, self->texs); |
763 | Append (maptex, self->tex, self->texs, self->texs); |
582 | self->texs *= 2; |
764 | self->texs *= 2; |
583 | } |
765 | } |
584 | |
766 | |
|
|
767 | { |
585 | maptex *tex = self->tex + texid; |
768 | maptex *tex = self->tex + texid; |
586 | |
769 | |
587 | tex->name = name; |
770 | tex->name = name; |
588 | tex->w = w; |
771 | tex->w = w; |
589 | tex->h = h; |
772 | tex->h = h; |
590 | tex->s = s; |
773 | tex->s = s; |
591 | tex->t = t; |
774 | tex->t = t; |
592 | tex->r = r; |
775 | tex->r = r; |
593 | tex->g = g; |
776 | tex->g = g; |
594 | tex->b = b; |
777 | tex->b = b; |
595 | tex->a = a; |
778 | tex->a = a; |
|
|
779 | } |
596 | } |
780 | } |
597 | |
781 | |
598 | int |
782 | int |
599 | ox (CFClient::Map self) |
783 | ox (CFClient::Map self) |
600 | ALIAS: |
784 | ALIAS: |
… | |
… | |
638 | map1a_update (CFClient::Map self, SV *data_) |
822 | map1a_update (CFClient::Map self, SV *data_) |
639 | CODE: |
823 | CODE: |
640 | { |
824 | { |
641 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
825 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
642 | 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; |
643 | |
829 | |
644 | while (data < data_end) |
830 | while (data < data_end) |
645 | { |
831 | { |
646 | int flags = (data [0] << 8) + data [1]; data += 2; |
832 | flags = (data [0] << 8) + data [1]; data += 2; |
647 | |
833 | |
648 | int x = ((flags >> 10) & 63) + self->x; |
834 | x = ((flags >> 10) & 63) + self->x; |
649 | int y = ((flags >> 4) & 63) + self->y; |
835 | y = ((flags >> 4) & 63) + self->y; |
650 | |
836 | |
651 | mapcell *cell = map_get_cell (self, x, y); |
837 | cell = map_get_cell (self, x, y); |
652 | |
838 | |
653 | if (flags & 15) |
839 | if (flags & 15) |
654 | { |
840 | { |
655 | if (cell->darkness < 0) |
841 | if (cell->darkness < 0) |
656 | { |
842 | { |
… | |
… | |
746 | |
932 | |
747 | void |
933 | void |
748 | 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) |
749 | PPCODE: |
935 | PPCODE: |
750 | { |
936 | { |
|
|
937 | int vx, vy; |
|
|
938 | int x, y, z; |
|
|
939 | int last_name; |
|
|
940 | mapface face; |
751 | int sw4 = (sw + 3) & ~3; |
941 | int sw4 = (sw + 3) & ~3; |
752 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
942 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
753 | uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); |
943 | uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); |
|
|
944 | |
754 | memset (darkness, 255, sw4 * sh); |
945 | memset (darkness, 255, sw4 * sh); |
755 | SvPOK_only (darkness_sv); |
946 | SvPOK_only (darkness_sv); |
756 | SvCUR_set (darkness_sv, sw4 * sh); |
947 | SvCUR_set (darkness_sv, sw4 * sh); |
757 | |
948 | |
758 | int vx = self->x + (self->w - sw) / 2 - shift_x; |
949 | vx = self->x + (self->w - sw) / 2 - shift_x; |
759 | int vy = self->y + (self->h - sh) / 2 - shift_y; |
950 | vy = self->y + (self->h - sh) / 2 - shift_y; |
760 | |
951 | |
761 | /* |
952 | /* |
762 | int vx = self->vx = self->w >= sw |
953 | int vx = self->vx = self->w >= sw |
763 | ? self->x + (self->w - sw) / 2 |
954 | ? self->x + (self->w - sw) / 2 |
764 | : 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)); |
… | |
… | |
773 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
964 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
774 | glEnable (GL_BLEND); |
965 | glEnable (GL_BLEND); |
775 | glEnable (GL_TEXTURE_2D); |
966 | glEnable (GL_TEXTURE_2D); |
776 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
967 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
777 | |
968 | |
778 | int x, y, z; |
|
|
779 | |
|
|
780 | int last_name = 0; |
|
|
781 | |
|
|
782 | glBegin (GL_QUADS); |
969 | glBegin (GL_QUADS); |
|
|
970 | |
|
|
971 | last_name = 0; |
783 | |
972 | |
784 | for (z = 0; z < 3; z++) |
973 | for (z = 0; z < 3; z++) |
785 | for (y = 0; y < sh; y++) |
974 | for (y = 0; y < sh; y++) |
786 | if (0 <= y + vy && y + vy < self->rows) |
975 | if (0 <= y + vy && y + vy < self->rows) |
787 | { |
976 | { |
… | |
… | |
794 | |
983 | |
795 | darkness[y * sw4 + x] = cell->darkness < 0 |
984 | darkness[y * sw4 + x] = cell->darkness < 0 |
796 | ? 255 - FOW_DARKNESS |
985 | ? 255 - FOW_DARKNESS |
797 | : 255 - cell->darkness; |
986 | : 255 - cell->darkness; |
798 | |
987 | |
799 | mapface face = cell->face [z]; |
988 | face = cell->face [z]; |
800 | |
989 | |
801 | if (face) |
990 | if (face) |
802 | { |
991 | { |
803 | maptex tex = self->tex [face]; |
992 | maptex tex = self->tex [face]; |
804 | |
993 | |
… | |
… | |
864 | for (x = x0; x < x1; x++) |
1053 | for (x = x0; x < x1; x++) |
865 | { |
1054 | { |
866 | if (row && row->c0 <= x && x < row->c1) |
1055 | if (row && row->c0 <= x && x < row->c1) |
867 | { |
1056 | { |
868 | mapcell *cell = row->col + (x - row->c0); |
1057 | mapcell *cell = row->col + (x - row->c0); |
869 | |
|
|
870 | uint8_t flags = 0; |
1058 | uint8_t flags = 0; |
871 | |
1059 | |
872 | if (cell->face [0]) flags |= 1; |
1060 | if (cell->face [0]) flags |= 1; |
873 | if (cell->face [1]) flags |= 2; |
1061 | if (cell->face [1]) flags |= 2; |
874 | if (cell->face [2]) flags |= 4; |
1062 | if (cell->face [2]) flags |= 4; |
… | |
… | |
908 | void |
1096 | void |
909 | 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) |
910 | PPCODE: |
1098 | PPCODE: |
911 | { |
1099 | { |
912 | int x, y, z; |
1100 | int x, y, z; |
|
|
1101 | int w, h; |
913 | int x1, y1; |
1102 | int x1, y1; |
914 | |
1103 | |
915 | if (*data++ != 0) |
1104 | if (*data++ != 0) |
916 | return; /* version mismatch */ |
1105 | return; /* version mismatch */ |
917 | |
1106 | |
918 | int w = *data++ << 8; w |= *data++; |
1107 | w = *data++ << 8; w |= *data++; |
919 | int h = *data++ << 8; h |= *data++; |
1108 | h = *data++ << 8; h |= *data++; |
920 | |
1109 | |
921 | // 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 |
922 | // TODO: treat rows as we treat |
1111 | // TODO: treat rows as we treat |
923 | map_get_row (self, y0 + self->y - self->oy);//D |
1112 | map_get_row (self, y0 + self->y - self->oy);//D |
924 | 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 |