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.269 by root, Sun Jul 20 03:46:02 2008 UTC vs.
Revision 1.279 by root, Thu Oct 2 15:59:40 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
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{
521 if (!svp || !SvTRUE (*svp)) 528 if (!svp || !SvTRUE (*svp))
522 return 0; 529 return 0;
523 530
524 return 1; 531 return 1;
525} 532}
533
534/******************************************************************************/
535
536/* process keyboard modifiers */
537static int
538mod_munge (int mod)
539{
540 mod &= MOD_MASK;
541
542 if (mod & (KMOD_META | KMOD_ALT))
543 mod |= KMOD_LRAM;
544
545 return mod;
546}
547
548static void
549deliantra_main ()
550{
551 char *argv[] = { 0 };
552 call_argv ("::main", G_DISCARD | G_VOID, argv);
553}
554
555#ifdef __MACOSX__
556 /* to due surprising braindamage on the side of SDL design, we
557 * do some mind-boggling hack here: SDL requires a custom main()
558 * on OS X, so... we provide one and call the original main(), which,
559 * due to share dlibrary magic, calls -lSDLmain's main, not perl's main,
560 * and which calls our main (== SDL_main) back.
561 */
562 extern C_LINKAGE int
563 main (int argc, char *argv[])
564 {
565 deliantra_main ();
566 }
567
568 #undef main
569
570 extern C_LINKAGE int main (int argc, char *argv[]);
571
572 static void
573 SDL_braino (void)
574 {
575 char *argv[] = { "deliantra client", 0 };
576 (main) (1, argv);
577 }
578#else
579 static void
580 SDL_braino (void)
581 {
582 deliantra_main ();
583 }
584#endif
526 585
527MODULE = Deliantra::Client PACKAGE = DC 586MODULE = Deliantra::Client PACKAGE = DC
528 587
529PROTOTYPES: ENABLE 588PROTOTYPES: ENABLE
530 589
559 const_iv (SDL_USEREVENT), 618 const_iv (SDL_USEREVENT),
560 619
561 const_iv (SDL_APPINPUTFOCUS), 620 const_iv (SDL_APPINPUTFOCUS),
562 const_iv (SDL_APPMOUSEFOCUS), 621 const_iv (SDL_APPMOUSEFOCUS),
563 const_iv (SDL_APPACTIVE), 622 const_iv (SDL_APPACTIVE),
623
624
625 const_iv (SDLK_UNKNOWN),
626 const_iv (SDLK_FIRST),
627 const_iv (SDLK_BACKSPACE),
628 const_iv (SDLK_TAB),
629 const_iv (SDLK_CLEAR),
630 const_iv (SDLK_RETURN),
631 const_iv (SDLK_PAUSE),
632 const_iv (SDLK_ESCAPE),
633 const_iv (SDLK_SPACE),
634 const_iv (SDLK_EXCLAIM),
635 const_iv (SDLK_QUOTEDBL),
636 const_iv (SDLK_HASH),
637 const_iv (SDLK_DOLLAR),
638 const_iv (SDLK_AMPERSAND),
639 const_iv (SDLK_QUOTE),
640 const_iv (SDLK_LEFTPAREN),
641 const_iv (SDLK_RIGHTPAREN),
642 const_iv (SDLK_ASTERISK),
643 const_iv (SDLK_PLUS),
644 const_iv (SDLK_COMMA),
645 const_iv (SDLK_MINUS),
646 const_iv (SDLK_PERIOD),
647 const_iv (SDLK_SLASH),
648 const_iv (SDLK_0),
649 const_iv (SDLK_1),
650 const_iv (SDLK_2),
651 const_iv (SDLK_3),
652 const_iv (SDLK_4),
653 const_iv (SDLK_5),
654 const_iv (SDLK_6),
655 const_iv (SDLK_7),
656 const_iv (SDLK_8),
657 const_iv (SDLK_9),
658 const_iv (SDLK_COLON),
659 const_iv (SDLK_SEMICOLON),
660 const_iv (SDLK_LESS),
661 const_iv (SDLK_EQUALS),
662 const_iv (SDLK_GREATER),
663 const_iv (SDLK_QUESTION),
664 const_iv (SDLK_AT),
665
666 const_iv (SDLK_LEFTBRACKET),
667 const_iv (SDLK_BACKSLASH),
668 const_iv (SDLK_RIGHTBRACKET),
669 const_iv (SDLK_CARET),
670 const_iv (SDLK_UNDERSCORE),
671 const_iv (SDLK_BACKQUOTE),
672 const_iv (SDLK_DELETE),
564 673
565 const_iv (SDLK_FIRST), 674 const_iv (SDLK_FIRST),
566 const_iv (SDLK_LAST), 675 const_iv (SDLK_LAST),
567 const_iv (SDLK_KP0), 676 const_iv (SDLK_KP0),
568 const_iv (SDLK_KP1), 677 const_iv (SDLK_KP1),
644 const_iv (KMOD_RMETA), 753 const_iv (KMOD_RMETA),
645 const_iv (KMOD_NUM), 754 const_iv (KMOD_NUM),
646 const_iv (KMOD_CAPS), 755 const_iv (KMOD_CAPS),
647 const_iv (KMOD_MODE), 756 const_iv (KMOD_MODE),
648 757
758 const_iv (KMOD_LRAM),
759
649 const_iv (MIX_DEFAULT_FORMAT), 760 const_iv (MIX_DEFAULT_FORMAT),
650 761
651 const_iv (SDL_INIT_TIMER), 762 const_iv (SDL_INIT_TIMER),
652 const_iv (SDL_INIT_AUDIO), 763 const_iv (SDL_INIT_AUDIO),
653 const_iv (SDL_INIT_VIDEO), 764 const_iv (SDL_INIT_VIDEO),
721#endif 832#endif
722} 833}
723 834
724char *SDL_GetError () 835char *SDL_GetError ()
725 836
837void SDL_braino ()
838
726int SDL_Init (U32 flags) 839int SDL_Init (U32 flags)
727 840
728int SDL_InitSubSystem (U32 flags) 841int SDL_InitSubSystem (U32 flags)
729 842
730void SDL_QuitSubSystem (U32 flags) 843void SDL_QuitSubSystem (U32 flags)
838 { 951 {
839 case SDL_KEYDOWN: 952 case SDL_KEYDOWN:
840 case SDL_KEYUP: 953 case SDL_KEYUP:
841 hv_store (hv, "state", 5, newSViv (ev.key.state), 0); 954 hv_store (hv, "state", 5, newSViv (ev.key.state), 0);
842 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); 955 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0);
843 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0); 956 hv_store (hv, "mod", 3, newSViv (mod_munge (ev.key.keysym.mod)), 0);
844 hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */ 957 hv_store (hv, "cmod", 4, newSViv (mod_munge (SDL_GetModState ())), 0); /* current mode */
845 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); 958 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0);
846 break; 959 break;
847 960
848 case SDL_ACTIVEEVENT: 961 case SDL_ACTIVEEVENT:
849 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 962 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
867 x = ev.motion.x; 980 x = ev.motion.x;
868 y = ev.motion.y; 981 y = ev.motion.y;
869 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); 982 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION));
870 } 983 }
871 984
872 hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); 985 hv_store (hv, "mod", 3, newSViv (mod_munge (SDL_GetModState ())), 0);
873 hv_store (hv, "state", 5, newSViv (state), 0); 986 hv_store (hv, "state", 5, newSViv (state), 0);
874 hv_store (hv, "x", 1, newSViv (x), 0); 987 hv_store (hv, "x", 1, newSViv (x), 0);
875 hv_store (hv, "y", 1, newSViv (y), 0); 988 hv_store (hv, "y", 1, newSViv (y), 0);
876 hv_store (hv, "xrel", 4, newSViv (xrel), 0); 989 hv_store (hv, "xrel", 4, newSViv (xrel), 0);
877 hv_store (hv, "yrel", 4, newSViv (yrel), 0); 990 hv_store (hv, "yrel", 4, newSViv (yrel), 0);
2138 { 2251 {
2139 mapcell *cell = row->col + (x + mx - row->c0); 2252 mapcell *cell = row->col + (x + mx - row->c0);
2140 2253
2141 int px = x * T; 2254 int px = x * T;
2142 int py = y * T; 2255 int py = y * T;
2256
2257 if (expect_false (cell->player == player))
2258 {
2259 px += sdx;
2260 py += sdy;
2261 }
2143 2262
2144 if (cell->stat_hp) 2263 if (cell->stat_hp)
2145 { 2264 {
2146 int width = cell->stat_width * T; 2265 int width = cell->stat_width * T;
2147 int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; 2266 int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width;
2888void glRotate (float angle, float x, float y, float z) 3007void glRotate (float angle, float x, float y, float z)
2889 CODE: 3008 CODE:
2890 glRotatef (angle, x, y, z); 3009 glRotatef (angle, x, y, z);
2891 3010
2892void glColor (float r, float g, float b, float a = 1.0) 3011void glColor (float r, float g, float b, float a = 1.0)
3012 PROTOTYPE: @
2893 ALIAS: 3013 ALIAS:
2894 glColor_premultiply = 1 3014 glColor_premultiply = 1
2895 CODE: 3015 CODE:
2896 if (ix) 3016 if (ix)
2897 { 3017 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines