Merge 0.9.24 master branch into sdl2.0

This commit is contained in:
Pere Pujal i Carabantes 2020-05-31 00:35:54 +02:00
commit 7769410b2e
18 changed files with 213 additions and 122 deletions

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - April 1, 2020
June 14, 2002 - May 23, 2020
*/
@ -478,6 +478,7 @@ static void mtw(wchar_t * wtok, char *tok)
#else
#include <librsvg/rsvg.h>
/* #include <librsvg/rsvg-cairo.h> -- Deprecated */
#if !defined(RSVG_H) || !defined(RSVG_CAIRO_H)
#error "---------------------------------------------------"
@ -1572,7 +1573,7 @@ static SDL_Surface *render_text(TuxPaint_Font * restrict font, const char *restr
if (font == NULL)
{
printf("render_text() received a NULL font!\n");
fprintf(stderr, "render_text() received a NULL font!\n");
fflush(stdout);
return NULL;
}
@ -2511,7 +2512,9 @@ static void mainloop(void)
#ifndef NOSOUND
if (use_sound)
{
#ifdef DEBUG
printf("modstate at mainloop %d, mod %d\n", SDL_GetModState(), mod);
#endif
mute = !mute;
Mix_HaltChannel(-1);
@ -8013,7 +8016,7 @@ int generate_fontconfig_cache_spinner(SDL_Surface * screen)
(event.type == SDL_KEYDOWN
&& (event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == SDLK_AC_BACK)))
{
printf("Aborting!\n");
fprintf(stderr, "Aborting!\n");
fflush(stdout);
return (1);
}
@ -8889,7 +8892,7 @@ static void draw_fonts(void)
if (tmp_surf_1 == NULL)
{
printf("render_text() returned NULL!\n");
fprintf(stderr, "render_text() returned NULL!\n");
return;
}
@ -11686,8 +11689,9 @@ static void load_starter_id(char *saved_id, FILE * fil)
tmp_ptr = fgets(template_id, sizeof(template_id), fi);
template_id[strlen(template_id) - 1] = '\0';
tmp = fscanf(fi, "%d", &template_personal);
/* FIXME: Debug only? */
#ifdef DEBUG
printf("template = %s\n (Personal=%d)", template_id, template_personal);
#endif
}
if (!feof(fi) && color_tag == 'M')
{
@ -13829,13 +13833,17 @@ static void do_png_embed_data(png_structp png_ptr)
if (SDL_MUSTLOCK(img_starter_bkgd))
SDL_UnlockSurface(img_starter_bkgd);
#ifdef DEBUG
printf("%d \n", (int)compressedLen);
#endif
compress(compressed_data, &compressedLen, sbk_pixs, img_starter_bkgd->h * img_starter_bkgd->w * 3);
set_chunk_data(&chunk_data, &chunk_data_len, img_starter_bkgd->w * img_starter_bkgd->h * 3, compressed_data,
compressedLen);
#ifdef DEBUG
printf("%d \n", (int)compressedLen);
#endif
tuxpaint_chunks[2].data = (png_byte *) chunk_data;
@ -14023,7 +14031,9 @@ static void do_png_embed_data(png_structp png_ptr)
fprintf(lfi, "\n\n");
}
current_node = current_node->next_to_up_label_node;
#ifdef DEBUG
printf("cur %p, red %p\n", current_node, first_label_node_in_redo_stack);
#endif
}
#ifdef fmemopen_alternative
@ -21885,7 +21895,9 @@ static void load_info_about_label_surface(FILE * lfi)
new_node->save_y = tmp_pos;
}
#ifdef DEBUG
printf("Original label size %dx%d\n", new_node->save_width, new_node->save_height);
#endif
tmp_fscanf_return = fscanf(lfi, "%d\n", &new_node->save_cur_font);
new_node->save_cur_font = 0;
@ -22344,7 +22356,7 @@ Bytef *get_chunk_data(FILE * fp, char *fname, png_structp png_ptr,
if (f > 3)
{
comp_buff[i - count] = unknown.data[i];
// printf("%d, %d, %d ",i-count, comp_buff[i - count], unknown.data[i]);
// printf("%d, %d, %d ",i-count, comp_buff[i - count], unknown.data[i]);
}
if (unknown.data[i] == '\n' && f < 4)
@ -22390,13 +22402,13 @@ Bytef *get_chunk_data(FILE * fp, char *fname, png_structp png_ptr,
if (unc_err != Z_STREAM_END)
{
printf("\n error %d, unc %d, comp %d\n", unc_err, *unc_size, comp);
fprintf(stderr, "\n error %d, unc %d, comp %d\n", unc_err, *unc_size, comp);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
free(comp_buff);
free(unc_buff);
printf("Can't recover the embedded data in %s, error in uncompressing data from %s\n\n", fname, chunk_name);
fprintf(stderr, "Can't recover the embedded data in %s, error in uncompressing data from %s\n\n", fname, chunk_name);
draw_tux_text(TUX_OOPS, strerror(errno), 0);
return (NULL);
}
@ -22430,8 +22442,10 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
png_uint_32 ww, hh;
png_uint_32 i, j;
#ifdef DEBUG
printf("Loading embedded data...\n");
printf("%s\n", fname);
#endif
fp = fopen(fname, "rb");
if (!fp)
@ -22453,7 +22467,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
}
else
{
#ifdef DEBUG
printf("%s\n", fname);
#endif
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
@ -22478,7 +22494,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
num_unknowns = (int)png_get_unknown_chunks(png_ptr, info_ptr, &unknowns);
#ifdef DEBUG
printf("num_unknowns %i\n", num_unknowns);
#endif
if (num_unknowns)
{
have_label_delta = have_label_data = have_background = have_foreground = FALSE;
@ -22492,11 +22510,15 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
blured when scaled one) */
for (u = 0; u < num_unknowns; u++)
{
#ifdef DEBUG
printf("%s, %d\n", unknowns[u].name, (int)unknowns[u].size);
#endif
if (chunk_is_valid("tpDT", unknowns[u]))
{
#ifdef DEBUG
printf("Valid tpDT\n");
#endif
fi = fmemopen(unknowns[u].data, unknowns[u].size, "r");
if (fi == NULL)
{
@ -22557,7 +22579,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
{
if (chunk_is_valid("tpLD", unknowns[u]))
{
#ifdef DEBUG
printf("Valid tpLD\n");
#endif
unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLD", unknowns[u], &unc_size);
if (unc_buff == NULL)
@ -22596,7 +22620,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
/* Label Data */
if (!disable_label && chunk_is_valid("tpLL", unknowns[u]))
{
#ifdef DEBUG
printf("Valid tpLL\n");
#endif
unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLL", unknowns[u], &unc_size);
if (unc_buff == NULL)
@ -22609,7 +22635,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
fi = fmemopen(unc_buff, unc_size, "rb");
if (fi == NULL)
{
printf("Can't recover the label data embedded in %s, error in create file stream\n\n",
fprintf(stderr, "Can't recover the label data embedded in %s, error in create file stream\n\n",
fname);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
@ -22625,7 +22651,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
free(unc_buff);
ldata = TRUE;
#ifdef DEBUG
printf("Out of label data\n");
#endif
}
}
}
@ -22650,8 +22678,10 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Gmask, 0);
if (aux_surf == NULL)
{
printf("Can't recover the background data embedded in %s, error in create aux image\n\n",
#ifdef DEBUG
fprintf(stderr, "Can't recover the background data embedded in %s, error in create aux image\n\n",
fname);
#endif
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
free(unc_buff);
@ -22663,7 +22693,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
}
SDL_LockSurface(aux_surf);
#ifdef DEBUG
printf("Bkgd!!!\n");
#endif
for (j = 0; j < hh; j++)
for (i = 0; i < ww; i++)
putpixels[aux_surf->format->BytesPerPixel] (aux_surf, i, j,
@ -22693,7 +22725,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
if ((starter_modified || !img_starter) && chunk_is_valid("tpFG", unknowns[u]))
{
#ifdef DEBUG
printf("Frgd!!!\n");
#endif
unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpFG", unknowns[u], &unc_size);
if (unc_buff == NULL)
@ -22705,7 +22739,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf)
canvas->format->Gmask, canvas->format->Gmask, TPAINT_AMASK);
if (aux_surf == NULL)
{
printf("Can't recover the foreground data embedded in %s, error in create aux image\n\n",
fprintf(stderr, "Can't recover the foreground data embedded in %s, error in create aux image\n\n",
fname);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
@ -23227,7 +23261,7 @@ static void setup_config(char *argv[])
{
if (strtof(tmpcfg.joystick_dev, NULL) < 0 || strtof(tmpcfg.joystick_dev, NULL) > 100)
{
printf("Joystick dev (now %s) must be between 0 and 100.\n", tmpcfg.joystick_dev);
fprintf(stderr, "Joystick dev (now %s) must be between 0 and 100.\n", tmpcfg.joystick_dev);
exit(1);
}
joystick_dev = strtof(tmpcfg.joystick_dev, NULL);
@ -23237,7 +23271,7 @@ static void setup_config(char *argv[])
{
if (strtof(tmpcfg.joystick_slowness, NULL) < 0 || strtof(tmpcfg.joystick_slowness, NULL) > 500)
{
printf("Joystick slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_slowness);
fprintf(stderr, "Joystick slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_slowness);
exit(1);
}
joystick_slowness = strtof(tmpcfg.joystick_slowness, NULL);
@ -23247,7 +23281,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_lowthreshold, NULL) < 0 || strtof(tmpcfg.joystick_lowthreshold, NULL) > 32766)
{
/* FIXME: Find better exit code */
printf("Joystick lower threshold (now %s) must be between 0 and 32766", tmpcfg.joystick_lowthreshold);
fprintf(stderr, "Joystick lower threshold (now %s) must be between 0 and 32766", tmpcfg.joystick_lowthreshold);
exit(1);
}
joystick_low_threshold = strtof(tmpcfg.joystick_lowthreshold, NULL);
@ -23257,7 +23291,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_maxsteps, NULL) < 1 || strtof(tmpcfg.joystick_maxsteps, NULL) > 7)
{
/* FIXME: Find better exit code */
printf("Joystick max steps (now %s) must be between 1 and 7", tmpcfg.joystick_maxsteps);
fprintf(stderr, "Joystick max steps (now %s) must be between 1 and 7", tmpcfg.joystick_maxsteps);
exit(1);
}
joystick_maxsteps = strtof(tmpcfg.joystick_maxsteps, NULL);
@ -23266,7 +23300,7 @@ static void setup_config(char *argv[])
{
if (strtof(tmpcfg.joystick_hat_slowness, NULL) < 0 || strtof(tmpcfg.joystick_hat_slowness, NULL) > 500)
{
printf("Joystick hat slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_hat_slowness);
fprintf(stderr, "Joystick hat slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_hat_slowness);
exit(1);
}
joystick_hat_slowness = strtof(tmpcfg.joystick_hat_slowness, NULL);
@ -23276,7 +23310,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_hat_timeout, NULL) < 0 || strtof(tmpcfg.joystick_hat_timeout, NULL) > 3000)
{
/* FIXME: Find better exit code */
printf("Joystick hat timeout (now %s) must be between 0 and 3000", tmpcfg.joystick_hat_timeout);
fprintf(stderr, "Joystick hat timeout (now %s) must be between 0 and 3000", tmpcfg.joystick_hat_timeout);
exit(1);
}
joystick_hat_timeout = strtof(tmpcfg.joystick_hat_timeout, NULL);
@ -23286,7 +23320,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_escape, NULL) < 0 || strtof(tmpcfg.joystick_button_escape, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button escape shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_escape);
fprintf(stderr, "Joystick button escape shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_escape);
exit(1);
}
joystick_button_escape = strtof(tmpcfg.joystick_button_escape, NULL);
@ -23297,7 +23331,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectbrushtool, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button brush tool shortcurt (now %s) must be between 0 and 254",
fprintf(stderr, "Joystick button brush tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectbrushtool);
exit(1);
}
@ -23309,7 +23343,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectstamptool, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button stamp tool shortcurt (now %s) must be between 0 and 254",
fprintf(stderr, "Joystick button stamp tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectstamptool);
exit(1);
}
@ -23321,7 +23355,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectlinestool, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button lines tool shortcurt (now %s) must be between 0 and 254",
fprintf(stderr, "Joystick button lines tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectlinestool);
exit(1);
}
@ -23333,7 +23367,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectshapestool, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button shapes tool shortcurt (now %s) must be between 0 and 254",
fprintf(stderr, "Joystick button shapes tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectshapestool);
exit(1);
}
@ -23345,7 +23379,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selecttexttool, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button text tool shortcurt (now %s) must be between 0 and 254",
fprintf(stderr, "Joystick button text tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selecttexttool);
exit(1);
}
@ -23357,7 +23391,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectlabeltool, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button label tool shortcurt (now %s) must be between 0 and 254",
fprintf(stderr, "Joystick button label tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectlabeltool);
exit(1);
}
@ -23369,7 +23403,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selectmagictool, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button magic tool shortcurt (now %s) must be between 0 and 254",
fprintf(stderr, "Joystick button magic tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectmagictool);
exit(1);
}
@ -23380,7 +23414,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_undo, NULL) < 0 || strtof(tmpcfg.joystick_button_undo, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button undo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_undo);
fprintf(stderr, "Joystick button undo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_undo);
exit(1);
}
joystick_button_undo = strtof(tmpcfg.joystick_button_undo, NULL);
@ -23390,7 +23424,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_redo, NULL) < 0 || strtof(tmpcfg.joystick_button_redo, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button redo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_redo);
fprintf(stderr, "Joystick button redo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_redo);
exit(1);
}
joystick_button_redo = strtof(tmpcfg.joystick_button_redo, NULL);
@ -23401,7 +23435,7 @@ static void setup_config(char *argv[])
|| strtof(tmpcfg.joystick_button_selecterasertool, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button eraser tool shortcurt (now %s) must be between 0 and 254",
fprintf(stderr, "Joystick button eraser tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selecterasertool);
exit(1);
}
@ -23412,7 +23446,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_new, NULL) < 0 || strtof(tmpcfg.joystick_button_new, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button new shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_new);
fprintf(stderr, "Joystick button new shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_new);
exit(1);
}
joystick_button_new = strtof(tmpcfg.joystick_button_new, NULL);
@ -23422,7 +23456,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_open, NULL) < 0 || strtof(tmpcfg.joystick_button_open, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button open shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_open);
fprintf(stderr, "Joystick button open shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_open);
exit(1);
}
joystick_button_open = strtof(tmpcfg.joystick_button_open, NULL);
@ -23432,7 +23466,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_save, NULL) < 0 || strtof(tmpcfg.joystick_button_save, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button save shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_save);
fprintf(stderr, "Joystick button save shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_save);
exit(1);
}
joystick_button_save = strtof(tmpcfg.joystick_button_save, NULL);
@ -23442,7 +23476,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_pagesetup, NULL) < 0 || strtof(tmpcfg.joystick_button_pagesetup, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button page setup shortcurt (now %s) must be between 0 and 254",
fprintf(stderr, "Joystick button page setup shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_pagesetup);
exit(1);
}
@ -23453,7 +23487,7 @@ static void setup_config(char *argv[])
if (strtof(tmpcfg.joystick_button_print, NULL) < 0 || strtof(tmpcfg.joystick_button_print, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick button print shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_print);
fprintf(stderr, "Joystick button print shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_print);
exit(1);
}
joystick_button_print = strtof(tmpcfg.joystick_button_print, NULL);
@ -23468,7 +23502,7 @@ static void setup_config(char *argv[])
if (strtof(token, NULL) < 0 || strtof(token, NULL) > 254)
{
/* FIXME: Find better exit code */
printf("Joystick buttons must be between 0 and 254 (don't like %s)", tmpcfg.joystick_buttons_ignore);
fprintf(stderr, "Joystick buttons must be between 0 and 254 (don't like %s)", tmpcfg.joystick_buttons_ignore);
exit(1);
}
joystick_buttons_ignore[joystick_buttons_ignore_len++] = strtof(token, NULL);
@ -23961,11 +23995,11 @@ static void setup(void)
if (joystick_dev == -1)
{
printf("%i joystick(s) were found:\n", SDL_NumJoysticks());
fprintf(stderr, "%i joystick(s) were found:\n", SDL_NumJoysticks());
for (i = 0; i < SDL_NumJoysticks(); i++)
{
printf(" %d: %s\n", i, SDL_JoystickName(i));
fprintf(stderr, " %d: %s\n", i, SDL_JoystickName(i));
}
SDL_Quit();
@ -25225,7 +25259,9 @@ static int trash(char *path)
return (unlink(path));
}
#ifdef DEBUG
printf("trash: basename=%s", basename(path)); /* EP */
#endif
strcpy(fname, basename(path));
if (!file_exists(path))