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.127 by root, Wed Jul 5 00:16:44 2006 UTC vs.
Revision 1.156 by root, Thu Sep 21 14:47:51 2006 UTC

1#ifdef _WIN32 1#ifdef _WIN32
2# define WIN32_LEAN_AND_MEAN
2# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls 3# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls
3# include <malloc.h> 4# include <malloc.h>
4# include <windows.h> 5# include <windows.h>
5# pragma warning(disable:4244) 6# pragma warning(disable:4244)
6#endif 7#endif
7 8
8#include "EXTERN.h" 9#include "EXTERN.h"
9#include "perl.h" 10#include "perl.h"
10#include "XSUB.h" 11#include "XSUB.h"
12
13#ifdef _WIN32
14# undef pipe
15#endif
11 16
12#include <math.h> 17#include <math.h>
13#include <string.h> 18#include <string.h>
14#include <stdio.h> 19#include <stdio.h>
15#include <stdlib.h> 20#include <stdlib.h>
40 typedef signed char int8_t; 45 typedef signed char int8_t;
41 typedef signed short int16_t; 46 typedef signed short int16_t;
42 typedef signed int int32_t; 47 typedef signed int int32_t;
43#endif 48#endif
44 49
45#include "glext.h"
46
47#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ 50#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */
48 51
49#define FOW_DARKNESS 32 52#define FOW_DARKNESS 32
50 53
51#define MAP_EXTEND_X 32 54#define MAP_EXTEND_X 32
80 83
81#include "pango-font.c" 84#include "pango-font.c"
82#include "pango-fontmap.c" 85#include "pango-fontmap.c"
83#include "pango-render.c" 86#include "pango-render.c"
84 87
85typedef Mix_Chunk *CFClient__MixChunk; 88typedef Mix_Chunk *CFPlus__MixChunk;
86typedef Mix_Music *CFClient__MixMusic; 89typedef Mix_Music *CFPlus__MixMusic;
87 90
88typedef PangoFontDescription *CFClient__Font; 91typedef PangoFontDescription *CFPlus__Font;
89 92
90static int 93static int
91shape_attr_p (PangoLayoutRun *run) 94shape_attr_p (PangoLayoutRun *run)
92{ 95{
93 GSList *attrs = run->item->analysis.extra_attrs; 96 GSList *attrs = run->item->analysis.extra_attrs;
107 110
108typedef struct cf_layout { 111typedef struct cf_layout {
109 PangoLayout *pl; 112 PangoLayout *pl;
110 float r, g, b, a; // default color for rgba mode 113 float r, g, b, a; // default color for rgba mode
111 int base_height; 114 int base_height;
112 CFClient__Font font; 115 CFPlus__Font font;
113} *CFClient__Layout; 116} *CFPlus__Layout;
114 117
115static CFClient__Font default_font; 118static CFPlus__Font default_font;
116static PangoContext *opengl_context; 119static PangoContext *opengl_context;
117static PangoFontMap *opengl_fontmap; 120static PangoFontMap *opengl_fontmap;
118 121
119static void 122static void
120substitute_func (FcPattern *pattern, gpointer data) 123substitute_func (FcPattern *pattern, gpointer data)
125#endif 128#endif
126 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 129 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
127} 130}
128 131
129static void 132static void
130layout_update_font (CFClient__Layout self) 133layout_update_font (CFPlus__Layout self)
131{ 134{
132 /* use a random scale factor to account for unknown descenders, 0.8 works 135 /* use a random scale factor to account for unknown descenders, 0.8 works
133 * reasonably well with bitstream vera 136 * reasonably well with bitstream vera
134 */ 137 */
135 PangoFontDescription *font = self->font ? self->font : default_font; 138 PangoFontDescription *font = self->font ? self->font : default_font;
139 142
140 pango_layout_set_font_description (self->pl, font); 143 pango_layout_set_font_description (self->pl, font);
141} 144}
142 145
143static void 146static void
144layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 147layout_get_pixel_size (CFPlus__Layout self, int *w, int *h)
145{ 148{
149 PangoRectangle rect;
150
151 // get_pixel_* wrongly rounds down
146 pango_layout_get_pixel_size (self->pl, w, h); 152 pango_layout_get_extents (self->pl, 0, &rect);
147 153
148 if (!*w) *w = 1; 154 rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE;
149 if (!*h) *h = 1; 155 rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE;
150 156
151 *w = (*w + 3) & ~3; 157 if (!rect.width) rect.width = 1;
158 if (!rect.height) rect.height = 1;
159
160 *w = rect.width;
161 *h = rect.height;
152} 162}
153 163
154typedef uint16_t mapface; 164typedef uint16_t mapface;
155 165
156typedef struct { 166typedef struct {
159 float s, t; 169 float s, t;
160 uint8_t r, g, b, a; 170 uint8_t r, g, b, a;
161} maptex; 171} maptex;
162 172
163typedef struct { 173typedef struct {
164 int16_t darkness; 174 uint32_t player;
165 mapface face[3]; 175 mapface face[3];
176 uint16_t darkness;
177 uint8_t stat_width, stat_hp, flags;
166} mapcell; 178} mapcell;
167 179
168typedef struct { 180typedef struct {
169 int32_t c0, c1; 181 int32_t c0, c1;
170 mapcell *col; 182 mapcell *col;
179 int texs; 191 int texs;
180 maptex *tex; 192 maptex *tex;
181 193
182 int32_t rows; 194 int32_t rows;
183 maprow *row; 195 maprow *row;
184} *CFClient__Map; 196} *CFPlus__Map;
185 197
186static char * 198static char *
187prepend (char *ptr, int sze, int inc) 199prepend (char *ptr, int sze, int inc)
188{ 200{
189 char *p; 201 char *p;
207 219
208#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 220#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
209#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 221#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
210 222
211static maprow * 223static maprow *
212map_get_row (CFClient__Map self, int y) 224map_get_row (CFPlus__Map self, int y)
213{ 225{
214 if (0 > y) 226 if (0 > y)
215 { 227 {
216 int extend = - y + MAP_EXTEND_Y; 228 int extend = - y + MAP_EXTEND_Y;
217 Prepend (maprow, self->row, self->rows, extend); 229 Prepend (maprow, self->row, self->rows, extend);
255 267
256 return row->col + (x - row->c0); 268 return row->col + (x - row->c0);
257} 269}
258 270
259static mapcell * 271static mapcell *
260map_get_cell (CFClient__Map self, int x, int y) 272map_get_cell (CFPlus__Map self, int x, int y)
261{ 273{
262 return row_get_cell (map_get_row (self, y), x); 274 return row_get_cell (map_get_row (self, y), x);
263} 275}
264 276
265static void 277static void
266map_clear (CFClient__Map self) 278map_clear (CFPlus__Map self)
267{ 279{
268 int r; 280 int r;
269 281
270 for (r = 0; r < self->rows; r++) 282 for (r = 0; r < self->rows; r++)
271 Safefree (self->row[r].col); 283 Safefree (self->row[r].col);
279 self->row = 0; 291 self->row = 0;
280 self->rows = 0; 292 self->rows = 0;
281} 293}
282 294
283static void 295static void
284map_blank (CFClient__Map self, int x0, int y0, int w, int h) 296map_blank (CFPlus__Map self, int x0, int y0, int w, int h)
285{ 297{
286 int x, y; 298 int x, y;
287 maprow *row; 299 maprow *row;
300 mapcell *cell;
288 301
289 for (y = y0; y < y0 + h; y++) 302 for (y = y0; y < y0 + h; y++)
290 if (y >= 0) 303 if (y >= 0)
291 { 304 {
292 if (y >= self->rows) 305 if (y >= self->rows)
298 if (x >= row->c0) 311 if (x >= row->c0)
299 { 312 {
300 if (x >= row->c1) 313 if (x >= row->c1)
301 break; 314 break;
302 315
303 row->col[x - row->c0].darkness = -1; 316 cell = row->col + x - row->c0;
317
318 cell->darkness = 0;
319 cell->stat_hp = 0;
320 cell->flags = 0;
321 cell->player = 0;
304 } 322 }
305 } 323 }
306} 324}
307 325
308static void 326static void
346 n |= n >> 16; 364 n |= n >> 16;
347 365
348 return n + 1; 366 return n + 1;
349} 367}
350 368
351MODULE = CFClient PACKAGE = CFClient 369MODULE = CFPlus PACKAGE = CFPlus
352 370
353PROTOTYPES: ENABLE 371PROTOTYPES: ENABLE
354 372
355BOOT: 373BOOT:
356{ 374{
357 HV *stash = gv_stashpv ("CFClient", 1); 375 HV *stash = gv_stashpv ("CFPlus", 1);
358 static const struct { 376 static const struct {
359 const char *name; 377 const char *name;
360 IV iv; 378 IV iv;
361 } *civ, const_iv[] = { 379 } *civ, const_iv[] = {
362# define const_iv(name) { # name, (IV)name } 380# define const_iv(name) { # name, (IV)name }
463 481
464 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 482 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
465 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 483 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
466} 484}
467 485
486int
487in_destruct ()
488 CODE:
489 RETVAL = PL_main_cv == Nullcv;
490 OUTPUT:
491 RETVAL
492
468NV floor (NV x) 493NV floor (NV x)
469 494
470NV ceil (NV x) 495NV ceil (NV x)
471 496
472void 497void
502 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 527 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
503 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 528 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
504 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 529 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
505 530
506 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 531 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
532#if SDL_VERSION_ATLEAST(1,2,10)
533 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
534 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
535#endif
507 536
508 SDL_EnableUNICODE (1); 537 SDL_EnableUNICODE (1);
509 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 538 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
510 539
511 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 540 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
598 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 627 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
599 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 628 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
600 break; 629 break;
601 } 630 }
602 631
603 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 632 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
604 } 633 }
605} 634}
606 635
607int 636int
608Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) 637Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048)
624#endif 653#endif
625 654
626void 655void
627add_font (char *file) 656add_font (char *file)
628 CODE: 657 CODE:
629 FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ 658 FcConfigAppFontAddFile (0, (const FcChar8 *)file);
630 659
631void 660void
632load_image_inline (SV *image_) 661load_image_inline (SV *image_)
633 ALIAS: 662 ALIAS:
634 load_image_file = 1 663 load_image_file = 1
676 705
677 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); 706 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE);
678 707
679 assert (surface2->pitch == surface2->w * 4); 708 assert (surface2->pitch == surface2->w * 4);
680 709
710 SDL_LockSurface (surface2);
681 EXTEND (SP, 5); 711 EXTEND (SP, 6);
682 PUSHs (sv_2mortal (newSViv (surface2->w))); 712 PUSHs (sv_2mortal (newSViv (surface2->w)));
683 PUSHs (sv_2mortal (newSViv (surface2->h))); 713 PUSHs (sv_2mortal (newSViv (surface2->h)));
684 SDL_LockSurface (surface2);
685 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 714 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch)));
686 SDL_UnlockSurface (surface2);
687 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); 715 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
688 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 716 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
689 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); 717 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
718 SDL_UnlockSurface (surface2);
690 719
691 SDL_FreeSurface (surface); 720 SDL_FreeSurface (surface);
692 SDL_FreeSurface (surface2); 721 SDL_FreeSurface (surface2);
693} 722}
694 723
737void 766void
738_exit (int retval) 767_exit (int retval)
739 CODE: 768 CODE:
740 _exit (retval); 769 _exit (retval);
741 770
742MODULE = CFClient PACKAGE = CFClient::Font 771MODULE = CFPlus PACKAGE = CFPlus::Font
743 772
744CFClient::Font 773CFPlus::Font
745new_from_file (SV *class, char *path, int id = 0) 774new_from_file (SV *class, char *path, int id = 0)
746 CODE: 775 CODE:
747{ 776{
748 int count; 777 int count;
749 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 778 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
752} 781}
753 OUTPUT: 782 OUTPUT:
754 RETVAL 783 RETVAL
755 784
756void 785void
757DESTROY (CFClient::Font self) 786DESTROY (CFPlus::Font self)
758 CODE: 787 CODE:
759 pango_font_description_free (self); 788 pango_font_description_free (self);
760 789
761void 790void
762make_default (CFClient::Font self) 791make_default (CFPlus::Font self)
763 CODE: 792 CODE:
764 default_font = self; 793 default_font = self;
765 794
766MODULE = CFClient PACKAGE = CFClient::Layout 795MODULE = CFPlus PACKAGE = CFPlus::Layout
767 796
768void 797void
769clear_font_cache () 798reset_glyph_cache ()
770 CODE: 799 CODE:
771 tc_clear (); 800 tc_clear ();
772 801
773CFClient::Layout 802CFPlus::Layout
774new (SV *class, int type = 0) 803new (SV *class)
775 CODE: 804 CODE:
776 New (0, RETVAL, 1, struct cf_layout); 805 New (0, RETVAL, 1, struct cf_layout);
777 806
778 RETVAL->pl = pango_layout_new (opengl_context); 807 RETVAL->pl = pango_layout_new (opengl_context);
779 RETVAL->r = 1.; 808 RETVAL->r = 1.;
787 layout_update_font (RETVAL); 816 layout_update_font (RETVAL);
788 OUTPUT: 817 OUTPUT:
789 RETVAL 818 RETVAL
790 819
791void 820void
792DESTROY (CFClient::Layout self) 821DESTROY (CFPlus::Layout self)
793 CODE: 822 CODE:
794 g_object_unref (self->pl); 823 g_object_unref (self->pl);
795 Safefree (self); 824 Safefree (self);
796 825
797void 826void
798set_text (CFClient::Layout self, SV *text_) 827set_text (CFPlus::Layout self, SV *text_)
799 CODE: 828 CODE:
800{ 829{
801 STRLEN textlen; 830 STRLEN textlen;
802 char *text = SvPVutf8 (text_, textlen); 831 char *text = SvPVutf8 (text_, textlen);
803 832
804 pango_layout_set_text (self->pl, text, textlen); 833 pango_layout_set_text (self->pl, text, textlen);
805} 834}
806 835
807void 836void
808set_markup (CFClient::Layout self, SV *text_) 837set_markup (CFPlus::Layout self, SV *text_)
809 CODE: 838 CODE:
810{ 839{
811 STRLEN textlen; 840 STRLEN textlen;
812 char *text = SvPVutf8 (text_, textlen); 841 char *text = SvPVutf8 (text_, textlen);
813 842
814 pango_layout_set_markup (self->pl, text, textlen); 843 pango_layout_set_markup (self->pl, text, textlen);
815} 844}
816 845
817void 846void
818set_shapes (CFClient::Layout self, ...) 847set_shapes (CFPlus::Layout self, ...)
819 CODE: 848 CODE:
820{ 849{
821 PangoAttrList *attrs = 0; 850 PangoAttrList *attrs = 0;
822 const char *text = pango_layout_get_text (self->pl); 851 const char *text = pango_layout_get_text (self->pl);
823 const char *pos = text; 852 const char *pos = text;
858 if (attrs) 887 if (attrs)
859 pango_layout_set_attributes (self->pl, attrs); 888 pango_layout_set_attributes (self->pl, attrs);
860} 889}
861 890
862void 891void
863get_shapes (CFClient::Layout self) 892get_shapes (CFPlus::Layout self)
864 PPCODE: 893 PPCODE:
865{ 894{
866 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 895 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
867 896
868 do 897 do
872 if (run && shape_attr_p (run)) 901 if (run && shape_attr_p (run))
873 { 902 {
874 PangoRectangle extents; 903 PangoRectangle extents;
875 pango_layout_iter_get_run_extents (iter, 0, &extents); 904 pango_layout_iter_get_run_extents (iter, 0, &extents);
876 905
906 EXTEND (SP, 2);
877 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); 907 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x))));
878 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); 908 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y))));
879 } 909 }
880 } 910 }
881 while (pango_layout_iter_next_run (iter)); 911 while (pango_layout_iter_next_run (iter));
882 912
883 pango_layout_iter_free (iter); 913 pango_layout_iter_free (iter);
884} 914}
885 915
886int 916int
887has_wrapped (CFClient::Layout self) 917has_wrapped (CFPlus::Layout self)
888 CODE: 918 CODE:
889{ 919{
890 int lines = 1; 920 int lines = 1;
891 const char *text = pango_layout_get_text (self->pl); 921 const char *text = pango_layout_get_text (self->pl);
892 922
897} 927}
898 OUTPUT: 928 OUTPUT:
899 RETVAL 929 RETVAL
900 930
901SV * 931SV *
902get_text (CFClient::Layout self) 932get_text (CFPlus::Layout self)
903 CODE: 933 CODE:
904 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 934 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
905 sv_utf8_decode (RETVAL); 935 sv_utf8_decode (RETVAL);
906 OUTPUT: 936 OUTPUT:
907 RETVAL 937 RETVAL
908 938
909void 939void
910set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) 940set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.)
911 CODE: 941 CODE:
912 self->r = r; 942 self->r = r;
913 self->g = g; 943 self->g = g;
914 self->b = b; 944 self->b = b;
915 self->a = a; 945 self->a = a;
916 946
917void 947void
918set_font (CFClient::Layout self, CFClient::Font font = 0) 948set_font (CFPlus::Layout self, CFPlus::Font font = 0)
919 CODE: 949 CODE:
920 if (self->font != font) 950 if (self->font != font)
921 { 951 {
922 self->font = font; 952 self->font = font;
923 layout_update_font (self); 953 layout_update_font (self);
924 } 954 }
925 955
926void 956void
927set_height (CFClient::Layout self, int base_height) 957set_height (CFPlus::Layout self, int base_height)
928 CODE: 958 CODE:
929 if (self->base_height != base_height) 959 if (self->base_height != base_height)
930 { 960 {
931 self->base_height = base_height; 961 self->base_height = base_height;
932 layout_update_font (self); 962 layout_update_font (self);
933 } 963 }
934 964
935void 965void
936set_width (CFClient::Layout self, int max_width = -1) 966set_width (CFPlus::Layout self, int max_width = -1)
937 CODE: 967 CODE:
938 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); 968 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE);
939 969
940void 970void
941set_indent (CFClient::Layout self, int indent) 971set_indent (CFPlus::Layout self, int indent)
942 CODE: 972 CODE:
943 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 973 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
944 974
945void 975void
946set_spacing (CFClient::Layout self, int spacing) 976set_spacing (CFPlus::Layout self, int spacing)
947 CODE: 977 CODE:
948 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 978 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
949 979
950void 980void
951set_ellipsise (CFClient::Layout self, int ellipsise) 981set_ellipsise (CFPlus::Layout self, int ellipsise)
952 CODE: 982 CODE:
953 pango_layout_set_ellipsize (self->pl, 983 pango_layout_set_ellipsize (self->pl,
954 ellipsise == 1 ? PANGO_ELLIPSIZE_START 984 ellipsise == 1 ? PANGO_ELLIPSIZE_START
955 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 985 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
956 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 986 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
957 : PANGO_ELLIPSIZE_NONE 987 : PANGO_ELLIPSIZE_NONE
958 ); 988 );
959 989
960void 990void
961set_single_paragraph_mode (CFClient::Layout self, int spm) 991set_single_paragraph_mode (CFPlus::Layout self, int spm)
962 CODE: 992 CODE:
963 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 993 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
964 994
965void 995void
966size (CFClient::Layout self) 996size (CFPlus::Layout self)
967 PPCODE: 997 PPCODE:
968{ 998{
969 int w, h; 999 int w, h;
970 1000
971 layout_get_pixel_size (self, &w, &h); 1001 layout_get_pixel_size (self, &w, &h);
974 PUSHs (sv_2mortal (newSViv (w))); 1004 PUSHs (sv_2mortal (newSViv (w)));
975 PUSHs (sv_2mortal (newSViv (h))); 1005 PUSHs (sv_2mortal (newSViv (h)));
976} 1006}
977 1007
978int 1008int
979descent (CFClient::Layout self) 1009descent (CFPlus::Layout self)
980 CODE: 1010 CODE:
981{ 1011{
982 PangoRectangle rect; 1012 PangoRectangle rect;
983 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 1013 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0);
984 pango_layout_line_get_pixel_extents (line, 0, &rect); 1014 pango_layout_line_get_pixel_extents (line, 0, &rect);
986} 1016}
987 OUTPUT: 1017 OUTPUT:
988 RETVAL 1018 RETVAL
989 1019
990int 1020int
991xy_to_index (CFClient::Layout self, int x, int y) 1021xy_to_index (CFPlus::Layout self, int x, int y)
992 CODE: 1022 CODE:
993{ 1023{
994 int index, trailing; 1024 int index, trailing;
995 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); 1025 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing);
996 RETVAL = index; 1026 RETVAL = index;
997} 1027}
998 OUTPUT: 1028 OUTPUT:
999 RETVAL 1029 RETVAL
1000 1030
1001void 1031void
1002cursor_pos (CFClient::Layout self, int index) 1032cursor_pos (CFPlus::Layout self, int index)
1003 PPCODE: 1033 PPCODE:
1004{ 1034{
1005 PangoRectangle strong_pos; 1035 PangoRectangle strong_pos;
1006 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1036 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
1007 1037
1010 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1040 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1011 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1041 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1012} 1042}
1013 1043
1014void 1044void
1015render (CFClient::Layout self, float x, float y) 1045render (CFPlus::Layout self, float x, float y, int flags = 0)
1016 PPCODE: 1046 PPCODE:
1017 pango_opengl_render_layout_subpixel ( 1047 pango_opengl_render_layout_subpixel (
1018 self->pl, 1048 self->pl,
1019 x * PANGO_SCALE, y * PANGO_SCALE, 1049 x * PANGO_SCALE, y * PANGO_SCALE,
1020 self->r, self->g, self->b, self->a 1050 self->r, self->g, self->b, self->a,
1051 flags
1021 ); 1052 );
1022 1053
1023MODULE = CFClient PACKAGE = CFClient::Texture 1054MODULE = CFPlus PACKAGE = CFPlus::Texture
1024 1055
1025void 1056void
1026pad2pot (SV *data_, SV *w_, SV *h_) 1057pad2pot (SV *data_, SV *w_, SV *h_)
1027 CODE: 1058 CODE:
1028{ 1059{
1106 glDisable (GL_ALPHA_TEST); 1137 glDisable (GL_ALPHA_TEST);
1107 glDisable (GL_BLEND); 1138 glDisable (GL_BLEND);
1108 } 1139 }
1109} 1140}
1110 1141
1111MODULE = CFClient PACKAGE = CFClient::Map 1142MODULE = CFPlus PACKAGE = CFPlus::Map
1112 1143
1113CFClient::Map 1144CFPlus::Map
1114new (SV *class, int map_width, int map_height) 1145new (SV *class, int map_width, int map_height)
1115 CODE: 1146 CODE:
1116 New (0, RETVAL, 1, struct map); 1147 New (0, RETVAL, 1, struct map);
1117 RETVAL->x = 0; 1148 RETVAL->x = 0;
1118 RETVAL->y = 0; 1149 RETVAL->y = 0;
1128 RETVAL->row = 0; 1159 RETVAL->row = 0;
1129 OUTPUT: 1160 OUTPUT:
1130 RETVAL 1161 RETVAL
1131 1162
1132void 1163void
1133DESTROY (CFClient::Map self) 1164DESTROY (CFPlus::Map self)
1134 CODE: 1165 CODE:
1135{ 1166{
1136 map_clear (self); 1167 map_clear (self);
1137 Safefree (self->face); 1168 Safefree (self->face);
1138 Safefree (self->tex); 1169 Safefree (self->tex);
1139 Safefree (self); 1170 Safefree (self);
1140} 1171}
1141 1172
1142void 1173void
1143clear (CFClient::Map self) 1174clear (CFPlus::Map self)
1144 CODE: 1175 CODE:
1145 map_clear (self); 1176 map_clear (self);
1146 1177
1147void 1178void
1148set_face (CFClient::Map self, int face, int texid) 1179set_face (CFPlus::Map self, int face, int texid)
1149 CODE: 1180 CODE:
1150{ 1181{
1151 while (self->faces <= face) 1182 while (self->faces <= face)
1152 { 1183 {
1153 Append (mapface, self->face, self->faces, self->faces); 1184 Append (mapface, self->face, self->faces, self->faces);
1156 1187
1157 self->face [face] = texid; 1188 self->face [face] = texid;
1158} 1189}
1159 1190
1160void 1191void
1161set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) 1192set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a)
1162 CODE: 1193 CODE:
1163{ 1194{
1164 while (self->texs <= texid) 1195 while (self->texs <= texid)
1165 { 1196 {
1166 Append (maptex, self->tex, self->texs, self->texs); 1197 Append (maptex, self->tex, self->texs, self->texs);
1190 // from transparent color bleeding and ugly wrapping effects. 1221 // from transparent color bleeding and ugly wrapping effects.
1191 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1222 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1192} 1223}
1193 1224
1194int 1225int
1195ox (CFClient::Map self) 1226ox (CFPlus::Map self)
1196 ALIAS: 1227 ALIAS:
1197 oy = 1 1228 oy = 1
1198 x = 2 1229 x = 2
1199 y = 3 1230 y = 3
1200 w = 4 1231 w = 4
1211 } 1242 }
1212 OUTPUT: 1243 OUTPUT:
1213 RETVAL 1244 RETVAL
1214 1245
1215void 1246void
1216scroll (CFClient::Map self, int dx, int dy) 1247scroll (CFPlus::Map self, int dx, int dy)
1217 CODE: 1248 CODE:
1218{ 1249{
1219 if (dx > 0) 1250 if (dx > 0)
1220 map_blank (self, self->x, self->y, dx - 1, self->h); 1251 map_blank (self, self->x, self->y, dx, self->h);
1221 else if (dx < 0) 1252 else if (dx < 0)
1222 map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); 1253 map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h);
1223 1254
1224 if (dy > 0) 1255 if (dy > 0)
1225 map_blank (self, self->x, self->y, self->w, dy - 1); 1256 map_blank (self, self->x, self->y, self->w, dy);
1226 else if (dy < 0) 1257 else if (dy < 0)
1227 map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); 1258 map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy);
1228 1259
1229 self->ox += dx; self->x += dx; 1260 self->ox += dx; self->x += dx;
1230 self->oy += dy; self->y += dy; 1261 self->oy += dy; self->y += dy;
1231 1262
1232 while (self->y < 0) 1263 while (self->y < 0)
1237 self->y += MAP_EXTEND_Y; 1268 self->y += MAP_EXTEND_Y;
1238 } 1269 }
1239} 1270}
1240 1271
1241void 1272void
1242map1a_update (CFClient::Map self, SV *data_) 1273map1a_update (CFPlus::Map self, SV *data_, int extmap)
1243 CODE: 1274 CODE:
1244{ 1275{
1245 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1276 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1246 uint8_t *data_end = (uint8_t *)SvEND (data_); 1277 uint8_t *data_end = (uint8_t *)SvEND (data_);
1247 mapcell *cell; 1278 mapcell *cell;
1248 int x, y, flags; 1279 int x, y, flags;
1249 1280
1250 while (data < data_end) 1281 while (data < data_end - 1)
1251 { 1282 {
1252 flags = (data [0] << 8) + data [1]; data += 2; 1283 flags = (data [0] << 8) + data [1]; data += 2;
1253 1284
1254 x = self->x + ((flags >> 10) & 63); 1285 x = self->x + ((flags >> 10) & 63);
1255 y = self->y + ((flags >> 4) & 63); 1286 y = self->y + ((flags >> 4) & 63);
1256 1287
1257 cell = map_get_cell (self, x, y); 1288 cell = map_get_cell (self, x, y);
1258 1289
1259 if (flags & 15) 1290 if (flags & 15)
1260 { 1291 {
1261 if (cell->darkness < 0) 1292 if (!cell->darkness)
1262 { 1293 {
1294 memset (cell, 0, sizeof (*cell));
1263 cell->darkness = 0; 1295 cell->darkness = 256;
1264 cell->face [0] = 0;
1265 cell->face [1] = 0;
1266 cell->face [2] = 0;
1267 } 1296 }
1268 1297
1269 cell->darkness = flags & 8 ? *data++ : 255;
1270
1271 //TODO: don't trust server data to be in-range(!) 1298 //TODO: don't trust server data to be in-range(!)
1299
1300 if (flags & 8)
1301 {
1302 if (extmap)
1303 {
1304 uint8_t ext, cmd;
1305
1306 do
1307 {
1308 ext = *data++;
1309 cmd = ext & 0x3f;
1310
1311 if (cmd < 4)
1312 cell->darkness = 255 - ext * 64 + 1;
1313 else if (cmd == 5) // health
1314 {
1315 cell->stat_width = 1;
1316 cell->stat_hp = *data++;
1317 }
1318 else if (cmd == 6) // monster width
1319 cell->stat_width = *data++ + 1;
1320 else if (cmd == 0x47) // monster width
1321 {
1322 if (*data == 4)
1323 ; // decode player tag
1324
1325 data += *data + 1;
1326 }
1327 else if (cmd == 8) // cell flags
1328 cell->flags = *data++;
1329 else if (ext & 0x40) // unknown, multibyte => skip
1330 data += *data + 1;
1331 else
1332 data++;
1333 }
1334 while (ext & 0x80);
1335 }
1336 else
1337 cell->darkness = *data++ + 1;
1338 }
1272 1339
1273 if (flags & 4) 1340 if (flags & 4)
1274 { 1341 {
1275 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; 1342 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2;
1276 } 1343 }
1284 { 1351 {
1285 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1352 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1286 } 1353 }
1287 } 1354 }
1288 else 1355 else
1289 cell->darkness = -1; 1356 cell->darkness = 0;
1290 } 1357 }
1291} 1358}
1292 1359
1293SV * 1360SV *
1294mapmap (CFClient::Map self, int x0, int y0, int w, int h) 1361mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1295 CODE: 1362 CODE:
1296{ 1363{
1297 int x1, x; 1364 int x1, x;
1298 int y1, y; 1365 int y1, y;
1299 int z; 1366 int z;
1349} 1416}
1350 OUTPUT: 1417 OUTPUT:
1351 RETVAL 1418 RETVAL
1352 1419
1353void 1420void
1354draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1421draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1355 CODE: 1422 CODE:
1356{ 1423{
1357 int vx, vy; 1424 int vx, vy;
1358 int x, y, z; 1425 int x, y, z;
1359 int last_name; 1426 int last_name;
1394 { 1461 {
1395 mapcell *cell = row->col + (x + vx - row->c0); 1462 mapcell *cell = row->col + (x + vx - row->c0);
1396 1463
1397 face = cell->face [z]; 1464 face = cell->face [z];
1398 1465
1399 if (face) 1466 if (face && face < self->texs)
1400 { 1467 {
1401 maptex tex = self->tex [face]; 1468 maptex tex = self->tex [face];
1402
1403 int px = (x + 1) * 32 - tex.w; 1469 int px = (x + 1) * 32 - tex.w;
1404 int py = (y + 1) * 32 - tex.h; 1470 int py = (y + 1) * 32 - tex.h;
1405 1471
1406 if (last_name != tex.name) 1472 if (last_name != tex.name)
1407 { 1473 {
1408 glEnd (); 1474 glEnd ();
1409 last_name = tex.name;
1410 glBindTexture (GL_TEXTURE_2D, last_name); 1475 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1411 glBegin (GL_QUADS); 1476 glBegin (GL_QUADS);
1412 } 1477 }
1413 1478
1414 glTexCoord2f (0 , 0 ); glVertex2f (px , py ); 1479 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1415 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); 1480 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1416 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); 1481 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1417 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); 1482 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1418 } 1483 }
1484
1485 if (cell->flags && z == 2)
1486 {
1487 if (cell->flags & 1)
1488 {
1489 maptex tex = self->tex [1];
1490 int px = (x + 1) * 32 - tex.w + 2;
1491 int py = (y + 1) * 32 - tex.h - 6;
1492
1493 glEnd ();
1494 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1495 glBegin (GL_QUADS);
1496
1497 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1498 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1499 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1500 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1501 }
1502 }
1419 } 1503 }
1420 } 1504 }
1421 1505
1422 glEnd (); 1506 glEnd ();
1423 1507
1424 glDisable (GL_TEXTURE_2D); 1508 glDisable (GL_TEXTURE_2D);
1425 glDisable (GL_BLEND); 1509 glDisable (GL_BLEND);
1426}
1427 1510
1511 // top layer: overlays such as the health bar
1512 for (y = 0; y < sh; y++)
1513 if (0 <= y + vy && y + vy < self->rows)
1514 {
1515 maprow *row = self->row + (y + vy);
1516
1517 for (x = 0; x < sw; x++)
1518 if (row->c0 <= x + vx && x + vx < row->c1)
1519 {
1520 mapcell *cell = row->col + (x + vx - row->c0);
1521
1522 int px = x * 32;
1523 int py = y * 32;
1524
1525 if (cell->stat_hp)
1526 {
1527 int width = cell->stat_width * 32;
1528 int thick = sh / 28 + 1 + cell->stat_width;
1529
1530 glColor3ub (0, 0, 0);
1531 glRectf (px + 1, py - thick - 2,
1532 px + width - 1, py);
1533
1534 glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0);
1535 glRectf (px + 2,
1536 py - thick - 1,
1537 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1);
1538 }
1539 }
1540 }
1541}
1542
1428void 1543void
1429draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) 1544draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1430 CODE: 1545 CODE:
1431{ 1546{
1432 static float color[16][3] = { 1547 static float color[16][3] = {
1433 { 0.00F, 0.00F, 0.00F }, 1548 { 0.00F, 0.00F, 0.00F },
1434 { 1.00F, 1.00F, 1.00F }, 1549 { 1.00F, 1.00F, 1.00F },
1484 glDisable (GL_BLEND); 1599 glDisable (GL_BLEND);
1485 glDisable (GL_TEXTURE_2D); 1600 glDisable (GL_TEXTURE_2D);
1486} 1601}
1487 1602
1488void 1603void
1489fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1604fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1490 PPCODE: 1605 PPCODE:
1491{ 1606{
1492 int vx, vy; 1607 int vx, vy;
1493 int x, y; 1608 int x, y;
1494 int sw4 = (sw + 3) & ~3; 1609 int sw4 = (sw + 3) & ~3;
1510 for (x = 0; x < sw; x++) 1625 for (x = 0; x < sw; x++)
1511 if (row->c0 <= x + vx && x + vx < row->c1) 1626 if (row->c0 <= x + vx && x + vx < row->c1)
1512 { 1627 {
1513 mapcell *cell = row->col + (x + vx - row->c0); 1628 mapcell *cell = row->col + (x + vx - row->c0);
1514 1629
1515 darkness[y * sw4 + x] = cell->darkness < 0 1630 darkness[y * sw4 + x] = cell->darkness
1631 ? 255 - (cell->darkness - 1)
1516 ? 255 - FOW_DARKNESS 1632 : 255 - FOW_DARKNESS;
1517 : 255 - cell->darkness;
1518 } 1633 }
1519 } 1634 }
1520 1635
1521 EXTEND (SP, 3); 1636 EXTEND (SP, 3);
1522 PUSHs (sv_2mortal (newSViv (sw4))); 1637 PUSHs (sv_2mortal (newSViv (sw4)));
1523 PUSHs (sv_2mortal (newSViv (sh))); 1638 PUSHs (sv_2mortal (newSViv (sh)));
1524 PUSHs (darkness_sv); 1639 PUSHs (darkness_sv);
1525} 1640}
1526 1641
1527SV * 1642SV *
1528get_rect (CFClient::Map self, int x0, int y0, int w, int h) 1643get_rect (CFPlus::Map self, int x0, int y0, int w, int h)
1529 CODE: 1644 CODE:
1530{ 1645{
1531 int x, y, x1, y1; 1646 int x, y, x1, y1;
1532 SV *data_sv = newSV (w * h * 7 + 5); 1647 SV *data_sv = newSV (w * h * 7 + 5);
1533 uint8_t *data = (uint8_t *)SvPVX (data_sv); 1648 uint8_t *data = (uint8_t *)SvPVX (data_sv);
1595} 1710}
1596 OUTPUT: 1711 OUTPUT:
1597 RETVAL 1712 RETVAL
1598 1713
1599void 1714void
1600set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1715set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data)
1601 PPCODE: 1716 PPCODE:
1602{ 1717{
1603 int x, y, z; 1718 int x, y, z;
1604 int w, h; 1719 int w, h;
1605 int x1, y1; 1720 int x1, y1;
1637 1752
1638 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } 1753 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; }
1639 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } 1754 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; }
1640 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } 1755 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; }
1641 1756
1642 if (cell->darkness <= 0) 1757 if (cell->darkness == 0)
1643 { 1758 {
1644 cell->darkness = -1; 1759 cell->darkness = 0;
1645 1760
1646 for (z = 0; z <= 2; z++) 1761 for (z = 0; z <= 2; z++)
1647 { 1762 {
1648 cell->face[z] = face[z]; 1763 cell->face[z] = face[z];
1649 1764
1654 } 1769 }
1655 } 1770 }
1656 } 1771 }
1657} 1772}
1658 1773
1659MODULE = CFClient PACKAGE = CFClient::MixChunk 1774MODULE = CFPlus PACKAGE = CFPlus::MixChunk
1660 1775
1661CFClient::MixChunk 1776CFPlus::MixChunk
1662new_from_file (SV *class, char *path) 1777new_from_file (SV *class, char *path)
1663 CODE: 1778 CODE:
1664 RETVAL = Mix_LoadWAV (path); 1779 RETVAL = Mix_LoadWAV (path);
1665 OUTPUT: 1780 OUTPUT:
1666 RETVAL 1781 RETVAL
1667 1782
1668void 1783void
1669DESTROY (CFClient::MixChunk self) 1784DESTROY (CFPlus::MixChunk self)
1670 CODE: 1785 CODE:
1671 Mix_FreeChunk (self); 1786 Mix_FreeChunk (self);
1672 1787
1673int 1788int
1674volume (CFClient::MixChunk self, int volume = -1) 1789volume (CFPlus::MixChunk self, int volume = -1)
1675 CODE: 1790 CODE:
1676 RETVAL = Mix_VolumeChunk (self, volume); 1791 RETVAL = Mix_VolumeChunk (self, volume);
1677 OUTPUT: 1792 OUTPUT:
1678 RETVAL 1793 RETVAL
1679 1794
1680int 1795int
1681play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) 1796play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1)
1682 CODE: 1797 CODE:
1683 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 1798 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
1684 OUTPUT: 1799 OUTPUT:
1685 RETVAL 1800 RETVAL
1686 1801
1687MODULE = CFClient PACKAGE = CFClient::MixMusic 1802MODULE = CFPlus PACKAGE = CFPlus::MixMusic
1688 1803
1689int 1804int
1690volume (int volume = -1) 1805volume (int volume = -1)
1691 CODE: 1806 CODE:
1692 RETVAL = Mix_VolumeMusic (volume); 1807 RETVAL = Mix_VolumeMusic (volume);
1693 OUTPUT: 1808 OUTPUT:
1694 RETVAL 1809 RETVAL
1695 1810
1696CFClient::MixMusic 1811CFPlus::MixMusic
1697new_from_file (SV *class, char *path) 1812new_from_file (SV *class, char *path)
1698 CODE: 1813 CODE:
1699 RETVAL = Mix_LoadMUS (path); 1814 RETVAL = Mix_LoadMUS (path);
1700 OUTPUT: 1815 OUTPUT:
1701 RETVAL 1816 RETVAL
1702 1817
1703void 1818void
1704DESTROY (CFClient::MixMusic self) 1819DESTROY (CFPlus::MixMusic self)
1705 CODE: 1820 CODE:
1706 Mix_FreeMusic (self); 1821 Mix_FreeMusic (self);
1707 1822
1708int 1823int
1709play (CFClient::MixMusic self, int loops = -1) 1824play (CFPlus::MixMusic self, int loops = -1)
1710 CODE: 1825 CODE:
1711 RETVAL = Mix_PlayMusic (self, loops); 1826 RETVAL = Mix_PlayMusic (self, loops);
1712 OUTPUT: 1827 OUTPUT:
1713 RETVAL 1828 RETVAL
1714 1829
1715MODULE = CFClient PACKAGE = CFClient::OpenGL 1830MODULE = CFPlus PACKAGE = CFPlus::OpenGL
1716 1831
1717BOOT: 1832BOOT:
1718{ 1833{
1719 HV *stash = gv_stashpv ("CFClient::OpenGL", 1); 1834 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1);
1720 static const struct { 1835 static const struct {
1721 const char *name; 1836 const char *name;
1722 IV iv; 1837 IV iv;
1723 } *civ, const_iv[] = { 1838 } *civ, const_iv[] = {
1724# define const_iv(name) { # name, (IV)name } 1839# define const_iv(name) { # name, (IV)name }
1787 const_iv (GL_SEPARABLE_2D), 1902 const_iv (GL_SEPARABLE_2D),
1788 const_iv (GL_CONVOLUTION_2D), 1903 const_iv (GL_CONVOLUTION_2D),
1789 const_iv (GL_CONVOLUTION_BORDER_MODE), 1904 const_iv (GL_CONVOLUTION_BORDER_MODE),
1790 const_iv (GL_CONSTANT_BORDER), 1905 const_iv (GL_CONSTANT_BORDER),
1791 const_iv (GL_LINES), 1906 const_iv (GL_LINES),
1907 const_iv (GL_LINE_STRIP),
1792 const_iv (GL_LINE_LOOP), 1908 const_iv (GL_LINE_LOOP),
1793 const_iv (GL_QUADS), 1909 const_iv (GL_QUADS),
1794 const_iv (GL_QUAD_STRIP), 1910 const_iv (GL_QUAD_STRIP),
1795 const_iv (GL_TRIANGLES), 1911 const_iv (GL_TRIANGLES),
1796 const_iv (GL_TRIANGLE_STRIP), 1912 const_iv (GL_TRIANGLE_STRIP),
1906 r *= a; 2022 r *= a;
1907 g *= a; 2023 g *= a;
1908 b *= a; 2024 b *= a;
1909 } 2025 }
1910 // microsoft visual "c" rounds instead of truncating... 2026 // microsoft visual "c" rounds instead of truncating...
1911 glColor4ub (MIN ((int)(r * 256.f), 255), 2027 glColor4f (r, g, b, a);
1912 MIN ((int)(g * 256.f), 255),
1913 MIN ((int)(b * 256.f), 255),
1914 MIN ((int)(a * 256.f), 255));
1915 2028
1916void glInterleavedArrays (int format, int stride, char *data) 2029void glInterleavedArrays (int format, int stride, char *data)
1917 2030
1918void glDrawElements (int mode, int count, int type, char *indices) 2031void glDrawElements (int mode, int count, int type, char *indices)
1919 2032
1996 2109
1997void glEndList () 2110void glEndList ()
1998 2111
1999void glCallList (int list) 2112void glCallList (int list)
2000 2113
2001

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines