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.263 by root, Fri Jul 18 21:18:42 2008 UTC vs.
Revision 1.284 by elmex, Thu Dec 11 00:17:47 2008 UTC

39#include <SDL_endian.h> 39#include <SDL_endian.h>
40#include <SDL_image.h> 40#include <SDL_image.h>
41#include <SDL_mixer.h> 41#include <SDL_mixer.h>
42#include <SDL_opengl.h> 42#include <SDL_opengl.h>
43 43
44/* work around os x broken headers */
45#ifdef __MACOSX__
46typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
47#endif
48
44#define PANGO_ENABLE_BACKEND 49#define PANGO_ENABLE_BACKEND
45#define G_DISABLE_CAST_CHECKS 50#define G_DISABLE_CAST_CHECKS
46 51
47#include <glib/gmacros.h> 52#include <glib/gmacros.h>
48 53
76#define expect_false(expr) expect ((expr) != 0, 0) 81#define expect_false(expr) expect ((expr) != 0, 0)
77#define expect_true(expr) expect ((expr) != 0, 1) 82#define expect_true(expr) expect ((expr) != 0, 1)
78 83
79#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ 84#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */
80 85
81#define FOW_DARKNESS 32 86#define FOW_DARKNESS 16
82 87
83#define MAP_EXTEND_X 32 88#define MAP_EXTEND_X 32
84#define MAP_EXTEND_Y 512 89#define MAP_EXTEND_Y 512
85 90
86#define MIN_FONT_HEIGHT 10 91#define MIN_FONT_HEIGHT 10
87 92
88/* mask out modifiers we are not interested in */ 93/* mask out modifiers we are not interested in */
89#define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) 94#define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META)
95
96#define KMOD_LRAM 0x10000 // our extension
90 97
91static AV *texture_av; 98static AV *texture_av;
92 99
93static struct 100static struct
94{ 101{
226 int w, h; 233 int w, h;
227 float s, t; 234 float s, t;
228 uint8_t r, g, b, a; 235 uint8_t r, g, b, a;
229 tileid smoothtile; 236 tileid smoothtile;
230 uint8_t smoothlevel; 237 uint8_t smoothlevel;
238 uint8_t unused; /* set to zero on use */
231} maptex; 239} maptex;
232 240
233typedef struct { 241typedef struct {
234 uint32_t player; 242 uint32_t player;
235 tileid tile[3]; 243 tileid tile[3];
367 self->oy = 0; 375 self->oy = 0;
368 self->row = 0; 376 self->row = 0;
369 self->rows = 0; 377 self->rows = 0;
370} 378}
371 379
380#define CELL_CLEAR(cell) \
381 do { \
382 if ((cell)->player) \
383 (cell)->tile [2] = 0; \
384 (cell)->darkness = 0; \
385 (cell)->stat_hp = 0; \
386 (cell)->flags = 0; \
387 (cell)->player = 0; \
388 } while (0)
389
372static void 390static void
373map_blank (DC__Map self, int x0, int y0, int w, int h) 391map_blank (DC__Map self, int x0, int y0, int w, int h)
374{ 392{
375 int x, y; 393 int x, y;
376 maprow *row; 394 maprow *row;
390 if (x >= row->c1) 408 if (x >= row->c1)
391 break; 409 break;
392 410
393 cell = row->col + x - row->c0; 411 cell = row->col + x - row->c0;
394 412
395 cell->darkness = 0; 413 CELL_CLEAR (cell);
396 cell->stat_hp = 0;
397 cell->flags = 0;
398 cell->player = 0;
399 } 414 }
400 } 415 }
401} 416}
402 417
403typedef struct { 418typedef struct {
514 if (!svp || !SvTRUE (*svp)) 529 if (!svp || !SvTRUE (*svp))
515 return 0; 530 return 0;
516 531
517 return 1; 532 return 1;
518} 533}
534
535/******************************************************************************/
536
537/* process keyboard modifiers */
538static int
539mod_munge (int mod)
540{
541 mod &= MOD_MASK;
542
543 if (mod & (KMOD_META | KMOD_ALT))
544 mod |= KMOD_LRAM;
545
546 return mod;
547}
548
549static void
550deliantra_main ()
551{
552 char *argv[] = { 0 };
553 call_argv ("::main", G_DISCARD | G_VOID, argv);
554}
555
556#ifdef __MACOSX__
557 /* to due surprising braindamage on the side of SDL design, we
558 * do some mind-boggling hack here: SDL requires a custom main()
559 * on OS X, so... we provide one and call the original main(), which,
560 * due to share dlibrary magic, calls -lSDLmain's main, not perl's main,
561 * and which calls our main (== SDL_main) back.
562 */
563 extern C_LINKAGE int
564 main (int argc, char *argv[])
565 {
566 deliantra_main ();
567 }
568
569 #undef main
570
571 extern C_LINKAGE int main (int argc, char *argv[]);
572
573 static void
574 SDL_braino (void)
575 {
576 char *argv[] = { "deliantra client", 0 };
577 (main) (1, argv);
578 }
579#else
580 static void
581 SDL_braino (void)
582 {
583 deliantra_main ();
584 }
585#endif
519 586
520MODULE = Deliantra::Client PACKAGE = DC 587MODULE = Deliantra::Client PACKAGE = DC
521 588
522PROTOTYPES: ENABLE 589PROTOTYPES: ENABLE
523 590
552 const_iv (SDL_USEREVENT), 619 const_iv (SDL_USEREVENT),
553 620
554 const_iv (SDL_APPINPUTFOCUS), 621 const_iv (SDL_APPINPUTFOCUS),
555 const_iv (SDL_APPMOUSEFOCUS), 622 const_iv (SDL_APPMOUSEFOCUS),
556 const_iv (SDL_APPACTIVE), 623 const_iv (SDL_APPACTIVE),
624
625
626 const_iv (SDLK_UNKNOWN),
627 const_iv (SDLK_FIRST),
628 const_iv (SDLK_BACKSPACE),
629 const_iv (SDLK_TAB),
630 const_iv (SDLK_CLEAR),
631 const_iv (SDLK_RETURN),
632 const_iv (SDLK_PAUSE),
633 const_iv (SDLK_ESCAPE),
634 const_iv (SDLK_SPACE),
635 const_iv (SDLK_EXCLAIM),
636 const_iv (SDLK_QUOTEDBL),
637 const_iv (SDLK_HASH),
638 const_iv (SDLK_DOLLAR),
639 const_iv (SDLK_AMPERSAND),
640 const_iv (SDLK_QUOTE),
641 const_iv (SDLK_LEFTPAREN),
642 const_iv (SDLK_RIGHTPAREN),
643 const_iv (SDLK_ASTERISK),
644 const_iv (SDLK_PLUS),
645 const_iv (SDLK_COMMA),
646 const_iv (SDLK_MINUS),
647 const_iv (SDLK_PERIOD),
648 const_iv (SDLK_SLASH),
649 const_iv (SDLK_0),
650 const_iv (SDLK_1),
651 const_iv (SDLK_2),
652 const_iv (SDLK_3),
653 const_iv (SDLK_4),
654 const_iv (SDLK_5),
655 const_iv (SDLK_6),
656 const_iv (SDLK_7),
657 const_iv (SDLK_8),
658 const_iv (SDLK_9),
659 const_iv (SDLK_COLON),
660 const_iv (SDLK_SEMICOLON),
661 const_iv (SDLK_LESS),
662 const_iv (SDLK_EQUALS),
663 const_iv (SDLK_GREATER),
664 const_iv (SDLK_QUESTION),
665 const_iv (SDLK_AT),
666
667 const_iv (SDLK_LEFTBRACKET),
668 const_iv (SDLK_BACKSLASH),
669 const_iv (SDLK_RIGHTBRACKET),
670 const_iv (SDLK_CARET),
671 const_iv (SDLK_UNDERSCORE),
672 const_iv (SDLK_BACKQUOTE),
673 const_iv (SDLK_DELETE),
557 674
558 const_iv (SDLK_FIRST), 675 const_iv (SDLK_FIRST),
559 const_iv (SDLK_LAST), 676 const_iv (SDLK_LAST),
560 const_iv (SDLK_KP0), 677 const_iv (SDLK_KP0),
561 const_iv (SDLK_KP1), 678 const_iv (SDLK_KP1),
637 const_iv (KMOD_RMETA), 754 const_iv (KMOD_RMETA),
638 const_iv (KMOD_NUM), 755 const_iv (KMOD_NUM),
639 const_iv (KMOD_CAPS), 756 const_iv (KMOD_CAPS),
640 const_iv (KMOD_MODE), 757 const_iv (KMOD_MODE),
641 758
759 const_iv (KMOD_LRAM),
760
642 const_iv (MIX_DEFAULT_FORMAT), 761 const_iv (MIX_DEFAULT_FORMAT),
643 762
644 const_iv (SDL_INIT_TIMER), 763 const_iv (SDL_INIT_TIMER),
645 const_iv (SDL_INIT_AUDIO), 764 const_iv (SDL_INIT_AUDIO),
646 const_iv (SDL_INIT_VIDEO), 765 const_iv (SDL_INIT_VIDEO),
647 const_iv (SDL_INIT_CDROM), 766 const_iv (SDL_INIT_CDROM),
648 const_iv (SDL_INIT_JOYSTICK), 767 const_iv (SDL_INIT_JOYSTICK),
649 const_iv (SDL_INIT_EVERYTHING), 768 const_iv (SDL_INIT_EVERYTHING),
650 const_iv (SDL_INIT_NOPARACHUTE), 769 const_iv (SDL_INIT_NOPARACHUTE),
651 const_iv (SDL_INIT_EVENTTHREAD), 770 const_iv (SDL_INIT_EVENTTHREAD),
771
772 const_iv (SDL_GL_RED_SIZE),
773 const_iv (SDL_GL_GREEN_SIZE),
774 const_iv (SDL_GL_BLUE_SIZE),
775 const_iv (SDL_GL_ALPHA_SIZE),
776 const_iv (SDL_GL_DOUBLEBUFFER),
777 const_iv (SDL_GL_BUFFER_SIZE),
778 const_iv (SDL_GL_DEPTH_SIZE),
779 const_iv (SDL_GL_STENCIL_SIZE),
780 const_iv (SDL_GL_ACCUM_RED_SIZE),
781 const_iv (SDL_GL_ACCUM_GREEN_SIZE),
782 const_iv (SDL_GL_ACCUM_BLUE_SIZE),
783 const_iv (SDL_GL_ACCUM_ALPHA_SIZE),
784 const_iv (SDL_GL_STEREO),
785 const_iv (SDL_GL_MULTISAMPLEBUFFERS),
786 const_iv (SDL_GL_MULTISAMPLESAMPLES),
787 const_iv (SDL_GL_ACCELERATED_VISUAL),
788 const_iv (SDL_GL_SWAP_CONTROL),
789
790 const_iv (FOW_DARKNESS)
652# undef const_iv 791# undef const_iv
653 }; 792 };
654 793
655 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 794 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
656 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 795 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
694#endif 833#endif
695} 834}
696 835
697char *SDL_GetError () 836char *SDL_GetError ()
698 837
838void SDL_braino ()
839
699int SDL_Init (U32 flags) 840int SDL_Init (U32 flags)
700 841
701int SDL_InitSubSystem (U32 flags) 842int SDL_InitSubSystem (U32 flags)
702 843
703void SDL_QuitSubSystem (U32 flags) 844void SDL_QuitSubSystem (U32 flags)
704 845
705void SDL_Quit () 846void SDL_Quit ()
847
848int SDL_GL_SetAttribute (int attr, int value)
849
850int SDL_GL_GetAttribute (int attr)
851 CODE:
852 if (SDL_GL_GetAttribute (attr, &RETVAL))
853 XSRETURN_UNDEF;
854 OUTPUT:
855 RETVAL
706 856
707void 857void
708SDL_ListModes (int rgb, int alpha) 858SDL_ListModes (int rgb, int alpha)
709 PPCODE: 859 PPCODE:
710{ 860{
722 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 872 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
723 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); 873 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0);
724 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 874 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
725 875
726 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 876 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
727#if SDL_VERSION_ATLEAST(1,2,10)
728 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
729 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); 877 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
730#endif
731 878
732 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 879 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
733 880
734 if (m && m != (SDL_Rect **)-1) 881 if (m && m != (SDL_Rect **)-1)
735 while (*m) 882 while (*m)
736 { 883 {
884 if ((*m)->w >= 400 && (*m)->h >= 300)
885 {
737 AV *av = newAV (); 886 AV *av = newAV ();
738 av_push (av, newSViv ((*m)->w)); 887 av_push (av, newSViv ((*m)->w));
739 av_push (av, newSViv ((*m)->h)); 888 av_push (av, newSViv ((*m)->h));
740 av_push (av, newSViv (rgb)); 889 av_push (av, newSViv (rgb));
741 av_push (av, newSViv (alpha)); 890 av_push (av, newSViv (alpha));
742 XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); 891 XPUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
892 }
743 893
744 ++m; 894 ++m;
745 } 895 }
746} 896}
747 897
802 { 952 {
803 case SDL_KEYDOWN: 953 case SDL_KEYDOWN:
804 case SDL_KEYUP: 954 case SDL_KEYUP:
805 hv_store (hv, "state", 5, newSViv (ev.key.state), 0); 955 hv_store (hv, "state", 5, newSViv (ev.key.state), 0);
806 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); 956 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0);
807 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0); 957 hv_store (hv, "mod", 3, newSViv (mod_munge (ev.key.keysym.mod)), 0);
808 hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */ 958 hv_store (hv, "cmod", 4, newSViv (mod_munge (SDL_GetModState ())), 0); /* current mode */
809 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); 959 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0);
810 break; 960 break;
811 961
812 case SDL_ACTIVEEVENT: 962 case SDL_ACTIVEEVENT:
813 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 963 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
831 x = ev.motion.x; 981 x = ev.motion.x;
832 y = ev.motion.y; 982 y = ev.motion.y;
833 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); 983 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION));
834 } 984 }
835 985
836 hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); 986 hv_store (hv, "mod", 3, newSViv (mod_munge (SDL_GetModState ())), 0);
837 hv_store (hv, "state", 5, newSViv (state), 0); 987 hv_store (hv, "state", 5, newSViv (state), 0);
838 hv_store (hv, "x", 1, newSViv (x), 0); 988 hv_store (hv, "x", 1, newSViv (x), 0);
839 hv_store (hv, "y", 1, newSViv (y), 0); 989 hv_store (hv, "y", 1, newSViv (y), 0);
840 hv_store (hv, "xrel", 4, newSViv (xrel), 0); 990 hv_store (hv, "xrel", 4, newSViv (xrel), 0);
841 hv_store (hv, "yrel", 4, newSViv (yrel), 0); 991 hv_store (hv, "yrel", 4, newSViv (yrel), 0);
1057#if DEBUG 1207#if DEBUG
1058 VALGRIND_DO_LEAK_CHECK; 1208 VALGRIND_DO_LEAK_CHECK;
1059#endif 1209#endif
1060} 1210}
1061 1211
1212int
1213SvREFCNT (SV *sv)
1214 CODE:
1215 RETVAL = SvREFCNT (sv);
1216 OUTPUT:
1217 RETVAL
1218
1062MODULE = Deliantra::Client PACKAGE = DC::Font 1219MODULE = Deliantra::Client PACKAGE = DC::Font
1063 1220
1064PROTOTYPES: DISABLE 1221PROTOTYPES: DISABLE
1065 1222
1066DC::Font 1223DC::Font
1610 //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 1767 //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1611 // use uglier nearest interpolation because linear suffers 1768 // use uglier nearest interpolation because linear suffers
1612 // from transparent color bleeding and ugly wrapping effects. 1769 // from transparent color bleeding and ugly wrapping effects.
1613 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1770 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1614} 1771}
1772
1773void
1774expire_textures (DC::Map self, int texid, int count)
1775 PPCODE:
1776 for (; texid < self->texs && count; ++texid, --count)
1777 {
1778 maptex *tex = self->tex + texid;
1779
1780 if (tex->name)
1781 {
1782 if (tex->unused)
1783 {
1784 tex->name = 0;
1785 tex->unused = 0;
1786 XPUSHs (sv_2mortal (newSViv (texid)));
1787 }
1788 else
1789 tex->unused = 1;
1790 }
1791 }
1615 1792
1616int 1793int
1617ox (DC::Map self) 1794ox (DC::Map self)
1618 ALIAS: 1795 ALIAS:
1619 oy = 1 1796 oy = 1
1740 cell->tile [z] = self->face2tile [face]; 1917 cell->tile [z] = self->face2tile [face];
1741 1918
1742 if (cell->tile [z]) 1919 if (cell->tile [z])
1743 { 1920 {
1744 maptex *tex = self->tex + cell->tile [z]; 1921 maptex *tex = self->tex + cell->tile [z];
1922 tex->unused = 0;
1745 if (!tex->name) 1923 if (!tex->name)
1746 av_push (missing, newSViv (cell->tile [z])); 1924 av_push (missing, newSViv (cell->tile [z]));
1747 1925
1748 if (tex->smoothtile) 1926 if (tex->smoothtile)
1749 { 1927 {
1750 maptex *smooth = self->tex + tex->smoothtile; 1928 maptex *smooth = self->tex + tex->smoothtile;
1929 smooth->unused = 0;
1751 if (!smooth->name) 1930 if (!smooth->name)
1752 av_push (missing, newSViv (tex->smoothtile)); 1931 av_push (missing, newSViv (tex->smoothtile));
1753 } 1932 }
1754 } 1933 }
1755 } 1934 }
1756 } 1935 }
1757 else 1936 else
1758 cell->darkness = 0; 1937 CELL_CLEAR (cell);
1759 } 1938 }
1760} 1939}
1761 OUTPUT: 1940 OUTPUT:
1762 RETVAL 1941 RETVAL
1763 1942
1815} 1994}
1816 OUTPUT: 1995 OUTPUT:
1817 RETVAL 1996 RETVAL
1818 1997
1819void 1998void
1820draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int pdx = 0, int pdy = 0) 1999draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0)
1821 CODE: 2000 CODE:
1822{ 2001{
1823 int x, y, z; 2002 int x, y, z;
1824 2003
1825 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 2004 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
1846 key.g = 255; 2025 key.g = 255;
1847 key.b = 255; 2026 key.b = 255;
1848 key.a = 255; 2027 key.a = 255;
1849 key.mode = GL_QUADS; 2028 key.mode = GL_QUADS;
1850 key.format = GL_T2F_V3F; 2029 key.format = GL_T2F_V3F;
1851 key.texname = -1;
1852 2030
1853 mx += self->x; 2031 mx += self->x;
1854 my += self->y; 2032 my += self->y;
1855 2033
1856 // first pass: determine smooth_max 2034 // first pass: determine smooth_max
1880 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 2058 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
1881 2059
1882 for (z = 0; z <= 2; z++) 2060 for (z = 0; z <= 2; z++)
1883 { 2061 {
1884 memset (smooth_level, 0, sizeof (smooth_level)); 2062 memset (smooth_level, 0, sizeof (smooth_level));
2063 key.texname = -1;
1885 2064
1886 for (y = 0; y < sh; y++) 2065 for (y = 0; y < sh; y++)
1887 if (0 <= y + my && y + my < self->rows) 2066 if (0 <= y + my && y + my < self->rows)
1888 { 2067 {
1889 maprow *row = self->row + (y + my); 2068 maprow *row = self->row + (y + my);
1900 int px = (x + 1) * T - tex.w; 2079 int px = (x + 1) * T - tex.w;
1901 int py = (y + 1) * T - tex.h; 2080 int py = (y + 1) * T - tex.h;
1902 2081
1903 if (key.texname != tex.name) 2082 if (key.texname != tex.name)
1904 { 2083 {
2084 self->tex [tile].unused = 0;
2085
1905 if (!tex.name) 2086 if (!tex.name)
1906 tex = self->tex [2]; /* missing, replace by noface */ 2087 tex = self->tex [2]; /* missing, replace by noface */
1907 2088
1908 key.texname = tex.name; 2089 key.texname = tex.name;
1909 arr = rc_array (rc, &key); 2090 arr = rc_array (rc, &key);
1922 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); 2103 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0);
1923 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); 2104 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0);
1924 2105
1925 if (expect_false (cell->flags) && expect_false (z == 2)) 2106 if (expect_false (cell->flags) && expect_false (z == 2))
1926 { 2107 {
2108 /* this is a workaround to make speech bubbles drawn
2109 * for example above walls, work. */
2110 rc_draw (rc);
2111 rc_clear (rc);
2112 key.texname = -1;
2113
1927 // overlays such as the speech bubble, probably more to come 2114 // overlays such as the speech bubble, probably more to come
1928 if (cell->flags & 1) 2115 if (cell->flags & 1)
1929 { 2116 {
1930 maptex tex = self->tex [1]; 2117 maptex tex = self->tex [1];
1931 int px = x * T + T * 2 / 32; 2118 int px = x * T + T * 2 / 32;
2031 { 2218 {
2032 // this time avoiding texture state changes 2219 // this time avoiding texture state changes
2033 // save gobs of state changes. 2220 // save gobs of state changes.
2034 if (key.texname != tex.name) 2221 if (key.texname != tex.name)
2035 { 2222 {
2223 self->tex [skey->tile].unused = 0;
2224
2036 glEnd (); 2225 glEnd ();
2037 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); 2226 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name);
2038 glBegin (GL_QUADS); 2227 glBegin (GL_QUADS);
2039 } 2228 }
2040 2229
2072 } 2261 }
2073 2262
2074 if (pl_tex.name) 2263 if (pl_tex.name)
2075 { 2264 {
2076 maptex tex = pl_tex; 2265 maptex tex = pl_tex;
2077 int px = pl_x + pdx; 2266 int px = pl_x + sdx;
2078 int py = pl_y + pdy; 2267 int py = pl_y + sdy;
2079 2268
2080 key.texname = tex.name; 2269 key.texname = tex.name;
2081 arr = rc_array (rc, &key); 2270 arr = rc_array (rc, &key);
2082 2271
2083 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2272 rc_t2f_v3f (arr, 0 , 0 , px , py , 0);
2102 { 2291 {
2103 mapcell *cell = row->col + (x + mx - row->c0); 2292 mapcell *cell = row->col + (x + mx - row->c0);
2104 2293
2105 int px = x * T; 2294 int px = x * T;
2106 int py = y * T; 2295 int py = y * T;
2296
2297 if (expect_false (cell->player == player))
2298 {
2299 px += sdx;
2300 py += sdy;
2301 }
2107 2302
2108 if (cell->stat_hp) 2303 if (cell->stat_hp)
2109 { 2304 {
2110 int width = cell->stat_width * T; 2305 int width = cell->stat_width * T;
2111 int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; 2306 int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width;
2200 SvCUR_set (darkness3_sv, sw34 * sh3); 2395 SvCUR_set (darkness3_sv, sw34 * sh3);
2201 2396
2202 mx += self->x - 1; 2397 mx += self->x - 1;
2203 my += self->y - 1; 2398 my += self->y - 1;
2204 2399
2205 memset (darkness1, 255, sw1 * sh1); 2400 memset (darkness1, 255 - FOW_DARKNESS, sw1 * sh1);
2206 2401
2207 for (y = 0; y < sh1; y++) 2402 for (y = 0; y < sh1; y++)
2208 if (0 <= y + my && y + my < self->rows) 2403 if (0 <= y + my && y + my < self->rows)
2209 { 2404 {
2210 maprow *row = self->row + (y + my); 2405 maprow *row = self->row + (y + my);
2852void glRotate (float angle, float x, float y, float z) 3047void glRotate (float angle, float x, float y, float z)
2853 CODE: 3048 CODE:
2854 glRotatef (angle, x, y, z); 3049 glRotatef (angle, x, y, z);
2855 3050
2856void glColor (float r, float g, float b, float a = 1.0) 3051void glColor (float r, float g, float b, float a = 1.0)
3052 PROTOTYPE: @
2857 ALIAS: 3053 ALIAS:
2858 glColor_premultiply = 1 3054 glColor_premultiply = 1
2859 CODE: 3055 CODE:
2860 if (ix) 3056 if (ix)
2861 { 3057 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines