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.264 by root, Fri Jul 18 22:32:54 2008 UTC vs.
Revision 1.273 by root, Wed Aug 20 13:30:02 2008 UTC

38#include <SDL_thread.h> 38#include <SDL_thread.h>
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
44/* work around os x broken headers */
45#ifdef __MACOSX__
46typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
47#endif
43 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>
367 self->oy = 0; 372 self->oy = 0;
368 self->row = 0; 373 self->row = 0;
369 self->rows = 0; 374 self->rows = 0;
370} 375}
371 376
377#define CELL_CLEAR(cell) \
378 do { \
379 if ((cell)->player) \
380 (cell)->tile [2] = 0; \
381 (cell)->darkness = 0; \
382 (cell)->stat_hp = 0; \
383 (cell)->flags = 0; \
384 (cell)->player = 0; \
385 } while (0)
386
372static void 387static void
373map_blank (DC__Map self, int x0, int y0, int w, int h) 388map_blank (DC__Map self, int x0, int y0, int w, int h)
374{ 389{
375 int x, y; 390 int x, y;
376 maprow *row; 391 maprow *row;
390 if (x >= row->c1) 405 if (x >= row->c1)
391 break; 406 break;
392 407
393 cell = row->col + x - row->c0; 408 cell = row->col + x - row->c0;
394 409
395 cell->darkness = 0; 410 CELL_CLEAR (cell);
396 cell->stat_hp = 0;
397 cell->flags = 0;
398 cell->player = 0;
399 } 411 }
400 } 412 }
401} 413}
402 414
403typedef struct { 415typedef struct {
514 if (!svp || !SvTRUE (*svp)) 526 if (!svp || !SvTRUE (*svp))
515 return 0; 527 return 0;
516 528
517 return 1; 529 return 1;
518} 530}
531
532static void
533deliantra_main ()
534{
535 char *argv[] = { 0 };
536 call_argv ("::main", G_DISCARD | G_VOID, argv);
537 dSP;
538}
539
540#ifdef __MACOSX__
541 /* to due surprising braindamage on the side of SDL design, we
542 * do some mind-boggling hack here: SDL requires a custom main()
543 * on OS X, so... we provide one and call the original main(), which,
544 * due to share dlibrary magic, calls -lSDLmain's main, not perl's main,
545 * and which calls our main (== SDL_main) back.
546 */
547 extern C_LINKAGE int
548 main (int argc, char *argv[])
549 {
550 deliantra_main ();
551 }
552
553 #undef main
554
555 extern C_LINKAGE int main (int argc, char *argv[]);
556
557 static void
558 SDL_braino (void)
559 {
560 char *argv[] = { "deliantra client", 0 };
561 (main) (1, argv);
562 }
563#else
564 static void
565 SDL_braino (void)
566 {
567 deliantra_main ();
568 }
569#endif
519 570
520MODULE = Deliantra::Client PACKAGE = DC 571MODULE = Deliantra::Client PACKAGE = DC
521 572
522PROTOTYPES: ENABLE 573PROTOTYPES: ENABLE
523 574
664 const_iv (SDL_GL_ACCUM_ALPHA_SIZE), 715 const_iv (SDL_GL_ACCUM_ALPHA_SIZE),
665 const_iv (SDL_GL_STEREO), 716 const_iv (SDL_GL_STEREO),
666 const_iv (SDL_GL_MULTISAMPLEBUFFERS), 717 const_iv (SDL_GL_MULTISAMPLEBUFFERS),
667 const_iv (SDL_GL_MULTISAMPLESAMPLES), 718 const_iv (SDL_GL_MULTISAMPLESAMPLES),
668 const_iv (SDL_GL_ACCELERATED_VISUAL), 719 const_iv (SDL_GL_ACCELERATED_VISUAL),
669 const_iv (SDL_GL_SWAP_CONTROL) 720 const_iv (SDL_GL_SWAP_CONTROL),
721
722 const_iv (FOW_DARKNESS)
670# undef const_iv 723# undef const_iv
671 }; 724 };
672 725
673 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 726 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
674 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 727 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
712#endif 765#endif
713} 766}
714 767
715char *SDL_GetError () 768char *SDL_GetError ()
716 769
770void SDL_braino ()
771
717int SDL_Init (U32 flags) 772int SDL_Init (U32 flags)
718 773
719int SDL_InitSubSystem (U32 flags) 774int SDL_InitSubSystem (U32 flags)
720 775
721void SDL_QuitSubSystem (U32 flags) 776void SDL_QuitSubSystem (U32 flags)
756 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 811 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
757 812
758 if (m && m != (SDL_Rect **)-1) 813 if (m && m != (SDL_Rect **)-1)
759 while (*m) 814 while (*m)
760 { 815 {
816 if ((*m)->w >= 400 && (*m)->h >= 300)
817 {
761 AV *av = newAV (); 818 AV *av = newAV ();
762 av_push (av, newSViv ((*m)->w)); 819 av_push (av, newSViv ((*m)->w));
763 av_push (av, newSViv ((*m)->h)); 820 av_push (av, newSViv ((*m)->h));
764 av_push (av, newSViv (rgb)); 821 av_push (av, newSViv (rgb));
765 av_push (av, newSViv (alpha)); 822 av_push (av, newSViv (alpha));
766 XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); 823 XPUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
824 }
767 825
768 ++m; 826 ++m;
769 } 827 }
770} 828}
771 829
1777 } 1835 }
1778 } 1836 }
1779 } 1837 }
1780 } 1838 }
1781 else 1839 else
1782 cell->darkness = 0; 1840 CELL_CLEAR (cell);
1783 } 1841 }
1784} 1842}
1785 OUTPUT: 1843 OUTPUT:
1786 RETVAL 1844 RETVAL
1787 1845
1839} 1897}
1840 OUTPUT: 1898 OUTPUT:
1841 RETVAL 1899 RETVAL
1842 1900
1843void 1901void
1844draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int pdx = 0, int pdy = 0) 1902draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0)
1845 CODE: 1903 CODE:
1846{ 1904{
1847 int x, y, z; 1905 int x, y, z;
1848 1906
1849 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 1907 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
2096 } 2154 }
2097 2155
2098 if (pl_tex.name) 2156 if (pl_tex.name)
2099 { 2157 {
2100 maptex tex = pl_tex; 2158 maptex tex = pl_tex;
2101 int px = pl_x + pdx; 2159 int px = pl_x + sdx;
2102 int py = pl_y + pdy; 2160 int py = pl_y + sdy;
2103 2161
2104 key.texname = tex.name; 2162 key.texname = tex.name;
2105 arr = rc_array (rc, &key); 2163 arr = rc_array (rc, &key);
2106 2164
2107 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2165 rc_t2f_v3f (arr, 0 , 0 , px , py , 0);
2224 SvCUR_set (darkness3_sv, sw34 * sh3); 2282 SvCUR_set (darkness3_sv, sw34 * sh3);
2225 2283
2226 mx += self->x - 1; 2284 mx += self->x - 1;
2227 my += self->y - 1; 2285 my += self->y - 1;
2228 2286
2229 memset (darkness1, 255, sw1 * sh1); 2287 memset (darkness1, 255 - FOW_DARKNESS, sw1 * sh1);
2230 2288
2231 for (y = 0; y < sh1; y++) 2289 for (y = 0; y < sh1; y++)
2232 if (0 <= y + my && y + my < self->rows) 2290 if (0 <= y + my && y + my < self->rows)
2233 { 2291 {
2234 maprow *row = self->row + (y + my); 2292 maprow *row = self->row + (y + my);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines