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.254 by root, Sun Jan 6 18:12:20 2008 UTC vs.
Revision 1.259 by root, Tue May 20 02:47:21 2008 UTC

51#ifndef PANGO_VERSION_CHECK 51#ifndef PANGO_VERSION_CHECK
52# define PANGO_VERSION_CHECK(a,b,c) 0 52# define PANGO_VERSION_CHECK(a,b,c) 0
53#endif 53#endif
54 54
55#if !PANGO_VERSION_CHECK (1, 15, 2) 55#if !PANGO_VERSION_CHECK (1, 15, 2)
56# define pango_layout_get_line_readonly pango_layout_get_line_readonly 56# define pango_layout_get_line_readonly pango_layout_get_line
57# define pango_layout_get_lines_readonly pango_layout_get_lines_readonly 57# define pango_layout_get_lines_readonly pango_layout_get_lines
58# define pango_layout_iter_get_line_readonly pango_layout_iter_get_line_readonly 58# define pango_layout_iter_get_line_readonly pango_layout_iter_get_line
59# define pango_layout_iter_get_run_readonly pango_layout_iter_get_run_readonly 59# define pango_layout_iter_get_run_readonly pango_layout_iter_get_run
60#endif 60#endif
61 61
62#ifndef _WIN32 62#ifndef _WIN32
63# include <sys/types.h> 63# include <sys/types.h>
64# include <sys/socket.h> 64# include <sys/socket.h>
185 185
186static void 186static void
187layout_update_font (DC__Layout self) 187layout_update_font (DC__Layout self)
188{ 188{
189 /* use a random scale factor to account for unknown descenders, 0.8 works 189 /* use a random scale factor to account for unknown descenders, 0.8 works
190 * reasonably well with bitstream vera 190 * reasonably well with dejavu/bistream fonts
191 */ 191 */
192 PangoFontDescription *font = self->font ? self->font : default_font; 192 PangoFontDescription *font = self->font ? self->font : default_font;
193 193
194 pango_font_description_set_absolute_size (font, 194 pango_font_description_set_absolute_size (font,
195 MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); 195 MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10));
673 CODE: 673 CODE:
674{ 674{
675 opengl_fontmap = pango_opengl_font_map_new (); 675 opengl_fontmap = pango_opengl_font_map_new ();
676 pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); 676 pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0);
677 opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); 677 opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap);
678 /*pango_context_set_font_description (opengl_context, default_font);*/
678#if PANGO_VERSION_CHECK (1, 15, 2) 679#if PANGO_VERSION_CHECK (1, 15, 2)
679 pango_context_set_language (opengl_context, pango_language_from_string ("en")); 680 pango_context_set_language (opengl_context, pango_language_from_string ("en"));
680 /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ 681 /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/
681#endif 682#endif
682} 683}
770SDL_GetKeyName (int sym) 771SDL_GetKeyName (int sym)
771 772
772int 773int
773SDL_GetAppState () 774SDL_GetAppState ()
774 775
776int
777SDL_GetModState ()
778
775void 779void
776poll_events () 780poll_events ()
777 PPCODE: 781 PPCODE:
778{ 782{
779 SDL_Event ev; 783 SDL_Event ev;
912 } 916 }
913 } 917 }
914#endif 918#endif
915} 919}
916 920
917void 921int
918add_font (char *file) 922add_font (char *file)
919 CODE: 923 CODE:
920 FcConfigAppFontAddFile (0, (const FcChar8 *)file); 924 RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file);
925 OUTPUT:
926 RETVAL
921 927
922void 928void
923load_image_inline (SV *image_) 929load_image_inline (SV *image_)
924 ALIAS: 930 ALIAS:
925 load_image_file = 1 931 load_image_file = 1
2286 else 2292 else
2287 *data++ = 0; 2293 *data++ = 0;
2288 } 2294 }
2289 } 2295 }
2290 2296
2297 if (data - (uint8_t *)SvPVX (data_sv) == w * h + 5)
2298 {
2299 SvREFCNT_dec (data_sv);
2300 RETVAL = &PL_sv_undef;
2301 }
2302 else
2303 {
2291 SvPOK_only (data_sv); 2304 SvPOK_only (data_sv);
2292 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); 2305 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv));
2293 RETVAL = data_sv; 2306 RETVAL = data_sv;
2307 }
2294} 2308}
2295 OUTPUT: 2309 OUTPUT:
2296 RETVAL 2310 RETVAL
2297 2311
2298void 2312void
2299set_rect (DC::Map self, int x0, int y0, uint8_t *data) 2313set_rect (DC::Map self, int x0, int y0, SV *data_sv)
2300 PPCODE: 2314 PPCODE:
2301{ 2315{
2302 int x, y, z; 2316 int x, y, z;
2303 int w, h; 2317 int w, h;
2304 int x1, y1; 2318 int x1, y1;
2319 STRLEN len;
2320 uint8_t *data, *end;
2321
2322 len = SvLEN (data_sv);
2323 SvGROW (data_sv, len + 7); // reserve at least 7+ bytes more
2324 data = SvPVbyte_nolen (data_sv);
2325 end = data + len + 7;
2326
2327 if (len < 5)
2328 XSRETURN_EMPTY;
2305 2329
2306 if (*data++ != 0) 2330 if (*data++ != 0)
2307 XSRETURN_EMPTY; /* version mismatch */ 2331 XSRETURN_EMPTY; /* version mismatch */
2308 2332
2309 w = *data++ << 8; w |= *data++; 2333 w = *data++ << 8; w |= *data++;
2324 { 2348 {
2325 maprow *row = map_get_row (self, y); 2349 maprow *row = map_get_row (self, y);
2326 2350
2327 for (x = x0; x < x1; x++) 2351 for (x = x0; x < x1; x++)
2328 { 2352 {
2353 uint8_t flags;
2354
2355 if (data + 7 >= end)
2356 XSRETURN_EMPTY;
2357
2329 uint8_t flags = *data++; 2358 flags = *data++;
2330 2359
2331 if (flags) 2360 if (flags)
2332 { 2361 {
2333 mapcell *cell = row_get_cell (row, x); 2362 mapcell *cell = row_get_cell (row, x);
2334 tileid tile[3] = { 0, 0, 0 }; 2363 tileid tile[3] = { 0, 0, 0 };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines