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.266 by root, Sun Jul 20 02:51:40 2008 UTC vs.
Revision 1.274 by root, Wed Aug 20 17:50:47 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}
538
539#ifdef __MACOSX__
540 /* to due surprising braindamage on the side of SDL design, we
541 * do some mind-boggling hack here: SDL requires a custom main()
542 * on OS X, so... we provide one and call the original main(), which,
543 * due to share dlibrary magic, calls -lSDLmain's main, not perl's main,
544 * and which calls our main (== SDL_main) back.
545 */
546 extern C_LINKAGE int
547 main (int argc, char *argv[])
548 {
549 deliantra_main ();
550 }
551
552 #undef main
553
554 extern C_LINKAGE int main (int argc, char *argv[]);
555
556 static void
557 SDL_braino (void)
558 {
559 char *argv[] = { "deliantra client", 0 };
560 (main) (1, argv);
561 }
562#else
563 static void
564 SDL_braino (void)
565 {
566 deliantra_main ();
567 }
568#endif
519 569
520MODULE = Deliantra::Client PACKAGE = DC 570MODULE = Deliantra::Client PACKAGE = DC
521 571
522PROTOTYPES: ENABLE 572PROTOTYPES: ENABLE
523 573
664 const_iv (SDL_GL_ACCUM_ALPHA_SIZE), 714 const_iv (SDL_GL_ACCUM_ALPHA_SIZE),
665 const_iv (SDL_GL_STEREO), 715 const_iv (SDL_GL_STEREO),
666 const_iv (SDL_GL_MULTISAMPLEBUFFERS), 716 const_iv (SDL_GL_MULTISAMPLEBUFFERS),
667 const_iv (SDL_GL_MULTISAMPLESAMPLES), 717 const_iv (SDL_GL_MULTISAMPLESAMPLES),
668 const_iv (SDL_GL_ACCELERATED_VISUAL), 718 const_iv (SDL_GL_ACCELERATED_VISUAL),
669 const_iv (SDL_GL_SWAP_CONTROL) 719 const_iv (SDL_GL_SWAP_CONTROL),
720
721 const_iv (FOW_DARKNESS)
670# undef const_iv 722# undef const_iv
671 }; 723 };
672 724
673 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 725 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
674 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 726 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
711 /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ 763 /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/
712#endif 764#endif
713} 765}
714 766
715char *SDL_GetError () 767char *SDL_GetError ()
768
769void SDL_braino ()
716 770
717int SDL_Init (U32 flags) 771int SDL_Init (U32 flags)
718 772
719int SDL_InitSubSystem (U32 flags) 773int SDL_InitSubSystem (U32 flags)
720 774
1780 } 1834 }
1781 } 1835 }
1782 } 1836 }
1783 } 1837 }
1784 else 1838 else
1785 { 1839 CELL_CLEAR (cell);
1786 cell->darkness = 0;
1787 cell->stat_hp = 0;
1788 cell->flags = 0;
1789 cell->player = 0;
1790 }
1791 } 1840 }
1792} 1841}
1793 OUTPUT: 1842 OUTPUT:
1794 RETVAL 1843 RETVAL
1795 1844
2232 SvCUR_set (darkness3_sv, sw34 * sh3); 2281 SvCUR_set (darkness3_sv, sw34 * sh3);
2233 2282
2234 mx += self->x - 1; 2283 mx += self->x - 1;
2235 my += self->y - 1; 2284 my += self->y - 1;
2236 2285
2237 memset (darkness1, 255, sw1 * sh1); 2286 memset (darkness1, 255 - FOW_DARKNESS, sw1 * sh1);
2238 2287
2239 for (y = 0; y < sh1; y++) 2288 for (y = 0; y < sh1; y++)
2240 if (0 <= y + my && y + my < self->rows) 2289 if (0 <= y + my && y + my < self->rows)
2241 { 2290 {
2242 maprow *row = self->row + (y + my); 2291 maprow *row = self->row + (y + my);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines