Minor fixes to the AquariaPSPBuilder tool. psp tip
authorachurch
Tue, 28 Feb 2012 00:34:11 +0900
branchpsp
changeset 688 3b4b0b14caa7
parent 687 874a99605d3d
Minor fixes to the AquariaPSPBuilder tool. - <zlib.h> is no longer included by current versions of libpng, so include it manually for the definition of Z_BEST_COMPRESSION. - Avoid crashing when "Recently Used" is selected in the GTK+ file chooser dialog. - Document the create-empty-file calls used to allow BBGE to load custom-format textures and MP3 audio files.
PSP/tools/AquariaPSPBuilder.c
--- a/PSP/tools/AquariaPSPBuilder.c	Sun Oct 02 20:52:06 2011 +0900
+++ b/PSP/tools/AquariaPSPBuilder.c	Tue Feb 28 00:34:11 2012 +0900
@@ -23,6 +23,7 @@
 #include <lame/lame.h>
 
 #define PNG_USER_MEM_SUPPORTED
+#include <zlib.h>
 #include <png.h>
 static jmp_buf png_jmpbuf;
 
@@ -526,6 +527,11 @@
 
     while (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
         char *path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+        if (!path) {
+            ui_show_error("Internal error: no filename returned!\n"
+                          "Make sure \"Recently Used\" is not selected.");
+            continue;
+        }
         char buf[10000];
         if (strlen(path+8) >= sizeof(buf)) {
             ui_show_error("Internal error: pathname too long!\n"
@@ -589,6 +595,11 @@
 
     while (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
         char *path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+        if (!path) {
+            ui_show_error("Internal error: no filename returned!\n"
+                          "Make sure \"Recently Used\" is not selected.");
+            continue;
+        }
         char buf[10000];
         if (strlen(path+8) >= sizeof(buf)) {
             ui_show_error("Internal error: pathname too long!\n"
@@ -890,7 +901,7 @@
                              1, TCV_ZOOM_CUBIC_KEYS4);
     if (!zi) {
         fprintf(stderr, "zoom_init() failed\n");
-        ui_oom();
+       ui_oom();
     }
     zoom_process(zi, texture->pixels, tempbuf);
     zoom_free(zi);
@@ -900,7 +911,7 @@
     texture->stride = new_stride;
     memcpy(texture->pixels, tempbuf, new_stride * new_height * 4);
     free(tempbuf);
-    
+
     /* Write out the icon as a PNG file. */
 
     if (!create_png(texture, &pngdata, &pngsize)) {
@@ -1042,6 +1053,7 @@
                 build_report_error(path, 0,
                                    &((GError){.message = "Failed to convert PNG image to PSP texture"}));
             }
+            /* Write out a dummy .png file so BBGE can find the texture. */
             build_write_file(out_path, path, "", 0);
             char *texpath = strdup(path);
             if (!texpath) {
@@ -1067,6 +1079,7 @@
                 build_report_error(path, 0,
                                    &((GError){.message = "Failed to convert Ogg audio to MP3"}));
             }
+            /* Write out a dummy .ogg file so BBGE can find the sound. */
             build_write_file(out_path, path, "", 0);
             char *mp3path = strdup(path);
             if (!mp3path) {