Provide blorb file to interpreter on command line
[projects/chimara/chimara.git] / libchimara / chimara-if.c
index 76edcf645c6252d07da503fb4b9895d099c70a73..2048f95d8783ee7df28adf825ce05f72da824f18 100644 (file)
@@ -650,6 +650,24 @@ chimara_if_run_game(ChimaraIF *self, gchar *gamefile, GError **error)
                        ;
        }
 
+       /* Check if an external blorb file is present */
+       /* FIXME: hardcoded path */
+       if(format == CHIMARA_IF_FORMAT_Z5 || format == CHIMARA_IF_FORMAT_Z6 || format == CHIMARA_IF_FORMAT_Z8) {
+               gchar *path = g_path_get_dirname(gamefile);
+               gchar *scratch = g_path_get_basename(gamefile);
+               *(strrchr(scratch, '.')) = '\0';
+               gchar *blorbfile = g_strconcat(path, "/../Resources/", scratch, ".blb", NULL);
+               g_printerr("Looking for %s\n", blorbfile);
+               if(g_file_test(blorbfile, G_FILE_TEST_EXISTS)) {
+                       args = g_slist_prepend(args, blorbfile);
+                       g_printerr("Prepending graphics file to args\n");
+               } else {
+                       g_free(blorbfile);
+               }
+               g_free(path);
+               g_free(scratch);
+       }
+
        /* Allocate argv to hold the arguments */
        int argc = g_slist_length(args);
        args = g_slist_prepend(args, NULL);
@@ -668,26 +686,6 @@ chimara_if_run_game(ChimaraIF *self, gchar *gamefile, GError **error)
        CHIMARA_GLK_USE_PRIVATE(self, glk_priv);
        glk_priv->story_name = g_path_get_basename(gamefile);
        g_object_notify(G_OBJECT(self), "story-name");
-
-       /* Check if an external blorb file is present */
-       /* FIXME: hardcoded path */
-       if(format == CHIMARA_IF_FORMAT_Z5
-           || format == CHIMARA_IF_FORMAT_Z6
-           || format == CHIMARA_IF_FORMAT_Z8
-           || format == CHIMARA_IF_FORMAT_GLULX) {
-               gchar *path = g_path_get_dirname(gamefile);
-               gchar *scratch = g_path_get_basename(gamefile);
-               *(strrchr(scratch, '.')) = '\0';
-               gchar *blorbfile = g_strconcat(path, "/../Resources/", scratch, ".blb", NULL);
-               if(g_file_test(blorbfile, G_FILE_TEST_EXISTS)) {
-                       glk_priv->open_external_blorb = TRUE;
-                       glk_priv->external_blorb_pathname = blorbfile;
-               } else {
-                       g_free(blorbfile);
-               }
-               g_free(path);
-               g_free(scratch);
-       }
        
        gboolean retval = chimara_glk_run(CHIMARA_GLK(self), pluginpath, argc, argv, error);
        g_free(argv);