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.132 by root, Sun Jul 23 04:37:51 2006 UTC vs.
Revision 1.141 by root, Fri Aug 18 01:01:00 2006 UTC

83 83
84#include "pango-font.c" 84#include "pango-font.c"
85#include "pango-fontmap.c" 85#include "pango-fontmap.c"
86#include "pango-render.c" 86#include "pango-render.c"
87 87
88typedef Mix_Chunk *CFClient__MixChunk; 88typedef Mix_Chunk *CFPlus__MixChunk;
89typedef Mix_Music *CFClient__MixMusic; 89typedef Mix_Music *CFPlus__MixMusic;
90 90
91typedef PangoFontDescription *CFClient__Font; 91typedef PangoFontDescription *CFPlus__Font;
92 92
93static int 93static int
94shape_attr_p (PangoLayoutRun *run) 94shape_attr_p (PangoLayoutRun *run)
95{ 95{
96 GSList *attrs = run->item->analysis.extra_attrs; 96 GSList *attrs = run->item->analysis.extra_attrs;
110 110
111typedef struct cf_layout { 111typedef struct cf_layout {
112 PangoLayout *pl; 112 PangoLayout *pl;
113 float r, g, b, a; // default color for rgba mode 113 float r, g, b, a; // default color for rgba mode
114 int base_height; 114 int base_height;
115 CFClient__Font font; 115 CFPlus__Font font;
116} *CFClient__Layout; 116} *CFPlus__Layout;
117 117
118static CFClient__Font default_font; 118static CFPlus__Font default_font;
119static PangoContext *opengl_context; 119static PangoContext *opengl_context;
120static PangoFontMap *opengl_fontmap; 120static PangoFontMap *opengl_fontmap;
121 121
122static void 122static void
123substitute_func (FcPattern *pattern, gpointer data) 123substitute_func (FcPattern *pattern, gpointer data)
128#endif 128#endif
129 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 129 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
130} 130}
131 131
132static void 132static void
133layout_update_font (CFClient__Layout self) 133layout_update_font (CFPlus__Layout self)
134{ 134{
135 /* 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
136 * reasonably well with bitstream vera 136 * reasonably well with bitstream vera
137 */ 137 */
138 PangoFontDescription *font = self->font ? self->font : default_font; 138 PangoFontDescription *font = self->font ? self->font : default_font;
142 142
143 pango_layout_set_font_description (self->pl, font); 143 pango_layout_set_font_description (self->pl, font);
144} 144}
145 145
146static void 146static void
147layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 147layout_get_pixel_size (CFPlus__Layout self, int *w, int *h)
148{ 148{
149 PangoRectangle rect;
150
151 // get_pixel_* wrongly rounds down
149 pango_layout_get_pixel_size (self->pl, w, h); 152 pango_layout_get_extents (self->pl, 0, &rect);
150 153
151 if (!*w) *w = 1; 154 rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE;
152 if (!*h) *h = 1; 155 rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE;
153 156
154 *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;
155} 162}
156 163
157typedef uint16_t mapface; 164typedef uint16_t mapface;
158 165
159typedef struct { 166typedef struct {
182 int texs; 189 int texs;
183 maptex *tex; 190 maptex *tex;
184 191
185 int32_t rows; 192 int32_t rows;
186 maprow *row; 193 maprow *row;
187} *CFClient__Map; 194} *CFPlus__Map;
188 195
189static char * 196static char *
190prepend (char *ptr, int sze, int inc) 197prepend (char *ptr, int sze, int inc)
191{ 198{
192 char *p; 199 char *p;
210 217
211#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 218#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
212#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 219#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
213 220
214static maprow * 221static maprow *
215map_get_row (CFClient__Map self, int y) 222map_get_row (CFPlus__Map self, int y)
216{ 223{
217 if (0 > y) 224 if (0 > y)
218 { 225 {
219 int extend = - y + MAP_EXTEND_Y; 226 int extend = - y + MAP_EXTEND_Y;
220 Prepend (maprow, self->row, self->rows, extend); 227 Prepend (maprow, self->row, self->rows, extend);
258 265
259 return row->col + (x - row->c0); 266 return row->col + (x - row->c0);
260} 267}
261 268
262static mapcell * 269static mapcell *
263map_get_cell (CFClient__Map self, int x, int y) 270map_get_cell (CFPlus__Map self, int x, int y)
264{ 271{
265 return row_get_cell (map_get_row (self, y), x); 272 return row_get_cell (map_get_row (self, y), x);
266} 273}
267 274
268static void 275static void
269map_clear (CFClient__Map self) 276map_clear (CFPlus__Map self)
270{ 277{
271 int r; 278 int r;
272 279
273 for (r = 0; r < self->rows; r++) 280 for (r = 0; r < self->rows; r++)
274 Safefree (self->row[r].col); 281 Safefree (self->row[r].col);
282 self->row = 0; 289 self->row = 0;
283 self->rows = 0; 290 self->rows = 0;
284} 291}
285 292
286static void 293static void
287map_blank (CFClient__Map self, int x0, int y0, int w, int h) 294map_blank (CFPlus__Map self, int x0, int y0, int w, int h)
288{ 295{
289 int x, y; 296 int x, y;
290 maprow *row; 297 maprow *row;
291 298
292 for (y = y0; y < y0 + h; y++) 299 for (y = y0; y < y0 + h; y++)
349 n |= n >> 16; 356 n |= n >> 16;
350 357
351 return n + 1; 358 return n + 1;
352} 359}
353 360
354MODULE = CFClient PACKAGE = CFClient 361MODULE = CFPlus PACKAGE = CFPlus
355 362
356PROTOTYPES: ENABLE 363PROTOTYPES: ENABLE
357 364
358BOOT: 365BOOT:
359{ 366{
360 HV *stash = gv_stashpv ("CFClient", 1); 367 HV *stash = gv_stashpv ("CFPlus", 1);
361 static const struct { 368 static const struct {
362 const char *name; 369 const char *name;
363 IV iv; 370 IV iv;
364 } *civ, const_iv[] = { 371 } *civ, const_iv[] = {
365# define const_iv(name) { # name, (IV)name } 372# define const_iv(name) { # name, (IV)name }
512 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 519 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
513 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 520 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
514 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 521 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
515 522
516 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 523 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
524#if SDL_VERSION_ATLEAST(1,2,10)
517 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); 525 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
518 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); 526 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
527#endif
519 528
520 SDL_EnableUNICODE (1); 529 SDL_EnableUNICODE (1);
521 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 530 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
522 531
523 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 532 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
610 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 619 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
611 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 620 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
612 break; 621 break;
613 } 622 }
614 623
615 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFClient::UI::Event", 1)))); 624 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
616 } 625 }
617} 626}
618 627
619int 628int
620Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) 629Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048)
749void 758void
750_exit (int retval) 759_exit (int retval)
751 CODE: 760 CODE:
752 _exit (retval); 761 _exit (retval);
753 762
754MODULE = CFClient PACKAGE = CFClient::Font 763MODULE = CFPlus PACKAGE = CFPlus::Font
755 764
756CFClient::Font 765CFPlus::Font
757new_from_file (SV *class, char *path, int id = 0) 766new_from_file (SV *class, char *path, int id = 0)
758 CODE: 767 CODE:
759{ 768{
760 int count; 769 int count;
761 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 770 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
764} 773}
765 OUTPUT: 774 OUTPUT:
766 RETVAL 775 RETVAL
767 776
768void 777void
769DESTROY (CFClient::Font self) 778DESTROY (CFPlus::Font self)
770 CODE: 779 CODE:
771 pango_font_description_free (self); 780 pango_font_description_free (self);
772 781
773void 782void
774make_default (CFClient::Font self) 783make_default (CFPlus::Font self)
775 CODE: 784 CODE:
776 default_font = self; 785 default_font = self;
777 786
778MODULE = CFClient PACKAGE = CFClient::Layout 787MODULE = CFPlus PACKAGE = CFPlus::Layout
779 788
780void 789void
781reset_glyph_cache () 790reset_glyph_cache ()
782 CODE: 791 CODE:
783 tc_clear (); 792 tc_clear ();
784 793
785CFClient::Layout 794CFPlus::Layout
786new (SV *class) 795new (SV *class)
787 CODE: 796 CODE:
788 New (0, RETVAL, 1, struct cf_layout); 797 New (0, RETVAL, 1, struct cf_layout);
789 798
790 RETVAL->pl = pango_layout_new (opengl_context); 799 RETVAL->pl = pango_layout_new (opengl_context);
799 layout_update_font (RETVAL); 808 layout_update_font (RETVAL);
800 OUTPUT: 809 OUTPUT:
801 RETVAL 810 RETVAL
802 811
803void 812void
804DESTROY (CFClient::Layout self) 813DESTROY (CFPlus::Layout self)
805 CODE: 814 CODE:
806 g_object_unref (self->pl); 815 g_object_unref (self->pl);
807 Safefree (self); 816 Safefree (self);
808 817
809void 818void
810set_text (CFClient::Layout self, SV *text_) 819set_text (CFPlus::Layout self, SV *text_)
811 CODE: 820 CODE:
812{ 821{
813 STRLEN textlen; 822 STRLEN textlen;
814 char *text = SvPVutf8 (text_, textlen); 823 char *text = SvPVutf8 (text_, textlen);
815 824
816 pango_layout_set_text (self->pl, text, textlen); 825 pango_layout_set_text (self->pl, text, textlen);
817} 826}
818 827
819void 828void
820set_markup (CFClient::Layout self, SV *text_) 829set_markup (CFPlus::Layout self, SV *text_)
821 CODE: 830 CODE:
822{ 831{
823 STRLEN textlen; 832 STRLEN textlen;
824 char *text = SvPVutf8 (text_, textlen); 833 char *text = SvPVutf8 (text_, textlen);
825 834
826 pango_layout_set_markup (self->pl, text, textlen); 835 pango_layout_set_markup (self->pl, text, textlen);
827} 836}
828 837
829void 838void
830set_shapes (CFClient::Layout self, ...) 839set_shapes (CFPlus::Layout self, ...)
831 CODE: 840 CODE:
832{ 841{
833 PangoAttrList *attrs = 0; 842 PangoAttrList *attrs = 0;
834 const char *text = pango_layout_get_text (self->pl); 843 const char *text = pango_layout_get_text (self->pl);
835 const char *pos = text; 844 const char *pos = text;
870 if (attrs) 879 if (attrs)
871 pango_layout_set_attributes (self->pl, attrs); 880 pango_layout_set_attributes (self->pl, attrs);
872} 881}
873 882
874void 883void
875get_shapes (CFClient::Layout self) 884get_shapes (CFPlus::Layout self)
876 PPCODE: 885 PPCODE:
877{ 886{
878 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 887 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
879 888
880 do 889 do
895 904
896 pango_layout_iter_free (iter); 905 pango_layout_iter_free (iter);
897} 906}
898 907
899int 908int
900has_wrapped (CFClient::Layout self) 909has_wrapped (CFPlus::Layout self)
901 CODE: 910 CODE:
902{ 911{
903 int lines = 1; 912 int lines = 1;
904 const char *text = pango_layout_get_text (self->pl); 913 const char *text = pango_layout_get_text (self->pl);
905 914
910} 919}
911 OUTPUT: 920 OUTPUT:
912 RETVAL 921 RETVAL
913 922
914SV * 923SV *
915get_text (CFClient::Layout self) 924get_text (CFPlus::Layout self)
916 CODE: 925 CODE:
917 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 926 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
918 sv_utf8_decode (RETVAL); 927 sv_utf8_decode (RETVAL);
919 OUTPUT: 928 OUTPUT:
920 RETVAL 929 RETVAL
921 930
922void 931void
923set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) 932set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.)
924 CODE: 933 CODE:
925 self->r = r; 934 self->r = r;
926 self->g = g; 935 self->g = g;
927 self->b = b; 936 self->b = b;
928 self->a = a; 937 self->a = a;
929 938
930void 939void
931set_font (CFClient::Layout self, CFClient::Font font = 0) 940set_font (CFPlus::Layout self, CFPlus::Font font = 0)
932 CODE: 941 CODE:
933 if (self->font != font) 942 if (self->font != font)
934 { 943 {
935 self->font = font; 944 self->font = font;
936 layout_update_font (self); 945 layout_update_font (self);
937 } 946 }
938 947
939void 948void
940set_height (CFClient::Layout self, int base_height) 949set_height (CFPlus::Layout self, int base_height)
941 CODE: 950 CODE:
942 if (self->base_height != base_height) 951 if (self->base_height != base_height)
943 { 952 {
944 self->base_height = base_height; 953 self->base_height = base_height;
945 layout_update_font (self); 954 layout_update_font (self);
946 } 955 }
947 956
948void 957void
949set_width (CFClient::Layout self, int max_width = -1) 958set_width (CFPlus::Layout self, int max_width = -1)
950 CODE: 959 CODE:
951 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); 960 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE);
952 961
953void 962void
954set_indent (CFClient::Layout self, int indent) 963set_indent (CFPlus::Layout self, int indent)
955 CODE: 964 CODE:
956 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 965 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
957 966
958void 967void
959set_spacing (CFClient::Layout self, int spacing) 968set_spacing (CFPlus::Layout self, int spacing)
960 CODE: 969 CODE:
961 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 970 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
962 971
963void 972void
964set_ellipsise (CFClient::Layout self, int ellipsise) 973set_ellipsise (CFPlus::Layout self, int ellipsise)
965 CODE: 974 CODE:
966 pango_layout_set_ellipsize (self->pl, 975 pango_layout_set_ellipsize (self->pl,
967 ellipsise == 1 ? PANGO_ELLIPSIZE_START 976 ellipsise == 1 ? PANGO_ELLIPSIZE_START
968 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 977 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
969 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 978 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
970 : PANGO_ELLIPSIZE_NONE 979 : PANGO_ELLIPSIZE_NONE
971 ); 980 );
972 981
973void 982void
974set_single_paragraph_mode (CFClient::Layout self, int spm) 983set_single_paragraph_mode (CFPlus::Layout self, int spm)
975 CODE: 984 CODE:
976 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 985 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
977 986
978void 987void
979size (CFClient::Layout self) 988size (CFPlus::Layout self)
980 PPCODE: 989 PPCODE:
981{ 990{
982 int w, h; 991 int w, h;
983 992
984 layout_get_pixel_size (self, &w, &h); 993 layout_get_pixel_size (self, &w, &h);
987 PUSHs (sv_2mortal (newSViv (w))); 996 PUSHs (sv_2mortal (newSViv (w)));
988 PUSHs (sv_2mortal (newSViv (h))); 997 PUSHs (sv_2mortal (newSViv (h)));
989} 998}
990 999
991int 1000int
992descent (CFClient::Layout self) 1001descent (CFPlus::Layout self)
993 CODE: 1002 CODE:
994{ 1003{
995 PangoRectangle rect; 1004 PangoRectangle rect;
996 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 1005 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0);
997 pango_layout_line_get_pixel_extents (line, 0, &rect); 1006 pango_layout_line_get_pixel_extents (line, 0, &rect);
999} 1008}
1000 OUTPUT: 1009 OUTPUT:
1001 RETVAL 1010 RETVAL
1002 1011
1003int 1012int
1004xy_to_index (CFClient::Layout self, int x, int y) 1013xy_to_index (CFPlus::Layout self, int x, int y)
1005 CODE: 1014 CODE:
1006{ 1015{
1007 int index, trailing; 1016 int index, trailing;
1008 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); 1017 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing);
1009 RETVAL = index; 1018 RETVAL = index;
1010} 1019}
1011 OUTPUT: 1020 OUTPUT:
1012 RETVAL 1021 RETVAL
1013 1022
1014void 1023void
1015cursor_pos (CFClient::Layout self, int index) 1024cursor_pos (CFPlus::Layout self, int index)
1016 PPCODE: 1025 PPCODE:
1017{ 1026{
1018 PangoRectangle strong_pos; 1027 PangoRectangle strong_pos;
1019 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1028 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
1020 1029
1023 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1032 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1024 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1033 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1025} 1034}
1026 1035
1027void 1036void
1028render (CFClient::Layout self, float x, float y) 1037render (CFPlus::Layout self, float x, float y, int flags = 0)
1029 PPCODE: 1038 PPCODE:
1030 pango_opengl_render_layout_subpixel ( 1039 pango_opengl_render_layout_subpixel (
1031 self->pl, 1040 self->pl,
1032 x * PANGO_SCALE, y * PANGO_SCALE, 1041 x * PANGO_SCALE, y * PANGO_SCALE,
1033 self->r, self->g, self->b, self->a 1042 self->r, self->g, self->b, self->a,
1043 flags
1034 ); 1044 );
1035 1045
1036MODULE = CFClient PACKAGE = CFClient::Texture 1046MODULE = CFPlus PACKAGE = CFPlus::Texture
1037 1047
1038void 1048void
1039pad2pot (SV *data_, SV *w_, SV *h_) 1049pad2pot (SV *data_, SV *w_, SV *h_)
1040 CODE: 1050 CODE:
1041{ 1051{
1119 glDisable (GL_ALPHA_TEST); 1129 glDisable (GL_ALPHA_TEST);
1120 glDisable (GL_BLEND); 1130 glDisable (GL_BLEND);
1121 } 1131 }
1122} 1132}
1123 1133
1124MODULE = CFClient PACKAGE = CFClient::Map 1134MODULE = CFPlus PACKAGE = CFPlus::Map
1125 1135
1126CFClient::Map 1136CFPlus::Map
1127new (SV *class, int map_width, int map_height) 1137new (SV *class, int map_width, int map_height)
1128 CODE: 1138 CODE:
1129 New (0, RETVAL, 1, struct map); 1139 New (0, RETVAL, 1, struct map);
1130 RETVAL->x = 0; 1140 RETVAL->x = 0;
1131 RETVAL->y = 0; 1141 RETVAL->y = 0;
1141 RETVAL->row = 0; 1151 RETVAL->row = 0;
1142 OUTPUT: 1152 OUTPUT:
1143 RETVAL 1153 RETVAL
1144 1154
1145void 1155void
1146DESTROY (CFClient::Map self) 1156DESTROY (CFPlus::Map self)
1147 CODE: 1157 CODE:
1148{ 1158{
1149 map_clear (self); 1159 map_clear (self);
1150 Safefree (self->face); 1160 Safefree (self->face);
1151 Safefree (self->tex); 1161 Safefree (self->tex);
1152 Safefree (self); 1162 Safefree (self);
1153} 1163}
1154 1164
1155void 1165void
1156clear (CFClient::Map self) 1166clear (CFPlus::Map self)
1157 CODE: 1167 CODE:
1158 map_clear (self); 1168 map_clear (self);
1159 1169
1160void 1170void
1161set_face (CFClient::Map self, int face, int texid) 1171set_face (CFPlus::Map self, int face, int texid)
1162 CODE: 1172 CODE:
1163{ 1173{
1164 while (self->faces <= face) 1174 while (self->faces <= face)
1165 { 1175 {
1166 Append (mapface, self->face, self->faces, self->faces); 1176 Append (mapface, self->face, self->faces, self->faces);
1169 1179
1170 self->face [face] = texid; 1180 self->face [face] = texid;
1171} 1181}
1172 1182
1173void 1183void
1174set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) 1184set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a)
1175 CODE: 1185 CODE:
1176{ 1186{
1177 while (self->texs <= texid) 1187 while (self->texs <= texid)
1178 { 1188 {
1179 Append (maptex, self->tex, self->texs, self->texs); 1189 Append (maptex, self->tex, self->texs, self->texs);
1203 // from transparent color bleeding and ugly wrapping effects. 1213 // from transparent color bleeding and ugly wrapping effects.
1204 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1214 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1205} 1215}
1206 1216
1207int 1217int
1208ox (CFClient::Map self) 1218ox (CFPlus::Map self)
1209 ALIAS: 1219 ALIAS:
1210 oy = 1 1220 oy = 1
1211 x = 2 1221 x = 2
1212 y = 3 1222 y = 3
1213 w = 4 1223 w = 4
1224 } 1234 }
1225 OUTPUT: 1235 OUTPUT:
1226 RETVAL 1236 RETVAL
1227 1237
1228void 1238void
1229scroll (CFClient::Map self, int dx, int dy) 1239scroll (CFPlus::Map self, int dx, int dy)
1230 CODE: 1240 CODE:
1231{ 1241{
1232 if (dx > 0) 1242 if (dx > 0)
1233 map_blank (self, self->x, self->y, dx - 1, self->h); 1243 map_blank (self, self->x, self->y, dx - 1, self->h);
1234 else if (dx < 0) 1244 else if (dx < 0)
1250 self->y += MAP_EXTEND_Y; 1260 self->y += MAP_EXTEND_Y;
1251 } 1261 }
1252} 1262}
1253 1263
1254void 1264void
1255map1a_update (CFClient::Map self, SV *data_) 1265map1a_update (CFPlus::Map self, SV *data_, int extmap)
1256 CODE: 1266 CODE:
1257{ 1267{
1258 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1268 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1259 uint8_t *data_end = (uint8_t *)SvEND (data_); 1269 uint8_t *data_end = (uint8_t *)SvEND (data_);
1260 mapcell *cell; 1270 mapcell *cell;
1277 cell->face [0] = 0; 1287 cell->face [0] = 0;
1278 cell->face [1] = 0; 1288 cell->face [1] = 0;
1279 cell->face [2] = 0; 1289 cell->face [2] = 0;
1280 } 1290 }
1281 1291
1292 if (flags & 8)
1293 {
1294 fprintf (stderr, "oi\n");//D
1295 if (extmap)
1296 {
1297 uint8_t ext, cmd;
1298
1299 do
1300 {
1301
1302 ext = *data++;
1303 cmd = ext & 0x7f;
1304
1305 fprintf (stderr, "extcmd = %x\n", ext);//D
1306
1307 if (ext < 4)
1308 cell->darkness = 255 - ext * 64;
1309 }
1310 while (cmd & 0x80);
1311 }
1312 else
1282 cell->darkness = flags & 8 ? *data++ : 255; 1313 cell->darkness = flags & 8 ? *data++ : 255;
1314 }
1283 1315
1284 //TODO: don't trust server data to be in-range(!) 1316 //TODO: don't trust server data to be in-range(!)
1285 1317
1286 if (flags & 4) 1318 if (flags & 4)
1287 { 1319 {
1302 cell->darkness = -1; 1334 cell->darkness = -1;
1303 } 1335 }
1304} 1336}
1305 1337
1306SV * 1338SV *
1307mapmap (CFClient::Map self, int x0, int y0, int w, int h) 1339mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1308 CODE: 1340 CODE:
1309{ 1341{
1310 int x1, x; 1342 int x1, x;
1311 int y1, y; 1343 int y1, y;
1312 int z; 1344 int z;
1362} 1394}
1363 OUTPUT: 1395 OUTPUT:
1364 RETVAL 1396 RETVAL
1365 1397
1366void 1398void
1367draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1399draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1368 CODE: 1400 CODE:
1369{ 1401{
1370 int vx, vy; 1402 int vx, vy;
1371 int x, y, z; 1403 int x, y, z;
1372 int last_name; 1404 int last_name;
1437 glDisable (GL_TEXTURE_2D); 1469 glDisable (GL_TEXTURE_2D);
1438 glDisable (GL_BLEND); 1470 glDisable (GL_BLEND);
1439} 1471}
1440 1472
1441void 1473void
1442draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) 1474draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1443 CODE: 1475 CODE:
1444{ 1476{
1445 static float color[16][3] = { 1477 static float color[16][3] = {
1446 { 0.00F, 0.00F, 0.00F }, 1478 { 0.00F, 0.00F, 0.00F },
1447 { 1.00F, 1.00F, 1.00F }, 1479 { 1.00F, 1.00F, 1.00F },
1497 glDisable (GL_BLEND); 1529 glDisable (GL_BLEND);
1498 glDisable (GL_TEXTURE_2D); 1530 glDisable (GL_TEXTURE_2D);
1499} 1531}
1500 1532
1501void 1533void
1502fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1534fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1503 PPCODE: 1535 PPCODE:
1504{ 1536{
1505 int vx, vy; 1537 int vx, vy;
1506 int x, y; 1538 int x, y;
1507 int sw4 = (sw + 3) & ~3; 1539 int sw4 = (sw + 3) & ~3;
1536 PUSHs (sv_2mortal (newSViv (sh))); 1568 PUSHs (sv_2mortal (newSViv (sh)));
1537 PUSHs (darkness_sv); 1569 PUSHs (darkness_sv);
1538} 1570}
1539 1571
1540SV * 1572SV *
1541get_rect (CFClient::Map self, int x0, int y0, int w, int h) 1573get_rect (CFPlus::Map self, int x0, int y0, int w, int h)
1542 CODE: 1574 CODE:
1543{ 1575{
1544 int x, y, x1, y1; 1576 int x, y, x1, y1;
1545 SV *data_sv = newSV (w * h * 7 + 5); 1577 SV *data_sv = newSV (w * h * 7 + 5);
1546 uint8_t *data = (uint8_t *)SvPVX (data_sv); 1578 uint8_t *data = (uint8_t *)SvPVX (data_sv);
1608} 1640}
1609 OUTPUT: 1641 OUTPUT:
1610 RETVAL 1642 RETVAL
1611 1643
1612void 1644void
1613set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1645set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data)
1614 PPCODE: 1646 PPCODE:
1615{ 1647{
1616 int x, y, z; 1648 int x, y, z;
1617 int w, h; 1649 int w, h;
1618 int x1, y1; 1650 int x1, y1;
1667 } 1699 }
1668 } 1700 }
1669 } 1701 }
1670} 1702}
1671 1703
1672MODULE = CFClient PACKAGE = CFClient::MixChunk 1704MODULE = CFPlus PACKAGE = CFPlus::MixChunk
1673 1705
1674CFClient::MixChunk 1706CFPlus::MixChunk
1675new_from_file (SV *class, char *path) 1707new_from_file (SV *class, char *path)
1676 CODE: 1708 CODE:
1677 RETVAL = Mix_LoadWAV (path); 1709 RETVAL = Mix_LoadWAV (path);
1678 OUTPUT: 1710 OUTPUT:
1679 RETVAL 1711 RETVAL
1680 1712
1681void 1713void
1682DESTROY (CFClient::MixChunk self) 1714DESTROY (CFPlus::MixChunk self)
1683 CODE: 1715 CODE:
1684 Mix_FreeChunk (self); 1716 Mix_FreeChunk (self);
1685 1717
1686int 1718int
1687volume (CFClient::MixChunk self, int volume = -1) 1719volume (CFPlus::MixChunk self, int volume = -1)
1688 CODE: 1720 CODE:
1689 RETVAL = Mix_VolumeChunk (self, volume); 1721 RETVAL = Mix_VolumeChunk (self, volume);
1690 OUTPUT: 1722 OUTPUT:
1691 RETVAL 1723 RETVAL
1692 1724
1693int 1725int
1694play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) 1726play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1)
1695 CODE: 1727 CODE:
1696 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 1728 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
1697 OUTPUT: 1729 OUTPUT:
1698 RETVAL 1730 RETVAL
1699 1731
1700MODULE = CFClient PACKAGE = CFClient::MixMusic 1732MODULE = CFPlus PACKAGE = CFPlus::MixMusic
1701 1733
1702int 1734int
1703volume (int volume = -1) 1735volume (int volume = -1)
1704 CODE: 1736 CODE:
1705 RETVAL = Mix_VolumeMusic (volume); 1737 RETVAL = Mix_VolumeMusic (volume);
1706 OUTPUT: 1738 OUTPUT:
1707 RETVAL 1739 RETVAL
1708 1740
1709CFClient::MixMusic 1741CFPlus::MixMusic
1710new_from_file (SV *class, char *path) 1742new_from_file (SV *class, char *path)
1711 CODE: 1743 CODE:
1712 RETVAL = Mix_LoadMUS (path); 1744 RETVAL = Mix_LoadMUS (path);
1713 OUTPUT: 1745 OUTPUT:
1714 RETVAL 1746 RETVAL
1715 1747
1716void 1748void
1717DESTROY (CFClient::MixMusic self) 1749DESTROY (CFPlus::MixMusic self)
1718 CODE: 1750 CODE:
1719 Mix_FreeMusic (self); 1751 Mix_FreeMusic (self);
1720 1752
1721int 1753int
1722play (CFClient::MixMusic self, int loops = -1) 1754play (CFPlus::MixMusic self, int loops = -1)
1723 CODE: 1755 CODE:
1724 RETVAL = Mix_PlayMusic (self, loops); 1756 RETVAL = Mix_PlayMusic (self, loops);
1725 OUTPUT: 1757 OUTPUT:
1726 RETVAL 1758 RETVAL
1727 1759
1728MODULE = CFClient PACKAGE = CFClient::OpenGL 1760MODULE = CFPlus PACKAGE = CFPlus::OpenGL
1729 1761
1730BOOT: 1762BOOT:
1731{ 1763{
1732 HV *stash = gv_stashpv ("CFClient::OpenGL", 1); 1764 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1);
1733 static const struct { 1765 static const struct {
1734 const char *name; 1766 const char *name;
1735 IV iv; 1767 IV iv;
1736 } *civ, const_iv[] = { 1768 } *civ, const_iv[] = {
1737# define const_iv(name) { # name, (IV)name } 1769# define const_iv(name) { # name, (IV)name }
1800 const_iv (GL_SEPARABLE_2D), 1832 const_iv (GL_SEPARABLE_2D),
1801 const_iv (GL_CONVOLUTION_2D), 1833 const_iv (GL_CONVOLUTION_2D),
1802 const_iv (GL_CONVOLUTION_BORDER_MODE), 1834 const_iv (GL_CONVOLUTION_BORDER_MODE),
1803 const_iv (GL_CONSTANT_BORDER), 1835 const_iv (GL_CONSTANT_BORDER),
1804 const_iv (GL_LINES), 1836 const_iv (GL_LINES),
1837 const_iv (GL_LINE_STRIP),
1805 const_iv (GL_LINE_LOOP), 1838 const_iv (GL_LINE_LOOP),
1806 const_iv (GL_QUADS), 1839 const_iv (GL_QUADS),
1807 const_iv (GL_QUAD_STRIP), 1840 const_iv (GL_QUAD_STRIP),
1808 const_iv (GL_TRIANGLES), 1841 const_iv (GL_TRIANGLES),
1809 const_iv (GL_TRIANGLE_STRIP), 1842 const_iv (GL_TRIANGLE_STRIP),
2006 2039
2007void glEndList () 2040void glEndList ()
2008 2041
2009void glCallList (int list) 2042void glCallList (int list)
2010 2043
2011

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines