From: P. F. Chimento Date: Sun, 30 Jan 2011 17:49:53 +0000 (+0100) Subject: Provide blorb file to interpreter on command line X-Git-Tag: v0.9~149 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=28c8862dc3d26a9a3735d0c2eb22ceb04be632c8;p=projects%2Fchimara%2Fchimara.git Provide blorb file to interpreter on command line Apparently both interpreters have the undocumented command line option of providing an extra file name on the command line, which is the Blorb resource file. We now take advantage of this. --- diff --git a/libchimara/chimara-glk-private.h b/libchimara/chimara-glk-private.h index 24d79fa..6736670 100644 --- a/libchimara/chimara-glk-private.h +++ b/libchimara/chimara-glk-private.h @@ -91,9 +91,6 @@ struct _ChimaraGlkPrivate { giblorb_map_t *resource_map; /* File stream pointing to the blorb used as current resource map */ strid_t resource_file; - /* Information for opening external blorb file */ - gboolean open_external_blorb; - gchar *external_blorb_pathname; /* Optional callback for loading resource data */ ChimaraResourceLoadFunc resource_load_callback; gpointer resource_load_callback_data; diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index aca2f21..ca01f44 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -180,8 +180,6 @@ chimara_glk_init(ChimaraGlk *self) priv->line_input_queue = g_async_queue_new(); /* Should be g_async_queue_new_full(g_free); but only in GTK >= 2.16 */ priv->resource_map = NULL; - priv->open_external_blorb = FALSE; - priv->external_blorb_pathname = NULL; priv->resource_lock = g_mutex_new(); priv->resource_loaded = g_cond_new(); priv->resource_info_available = g_cond_new(); @@ -1172,18 +1170,6 @@ glk_enter(struct StartupData *startup) if(!result) return NULL; } - - /* Open external Blorb file if specified */ - if(startup->glk_data->open_external_blorb) { - glkunix_set_base_file(startup->glk_data->external_blorb_pathname); - gchar *basename = g_path_get_basename(startup->glk_data->external_blorb_pathname); - frefid_t blorbref = glk_fileref_create_by_name(fileusage_BinaryMode | fileusage_Data, basename, 0); - g_free(basename); - strid_t blorbfile = glk_stream_open_file(blorbref, filemode_Read, 0); - giblorb_set_resource_map(blorbfile); - glk_fileref_destroy(blorbref); - g_printerr("Opening external blorb file\n"); - } /* Run main function */ glk_main_t glk_main = startup->glk_main; diff --git a/libchimara/chimara-if.c b/libchimara/chimara-if.c index 76edcf6..2048f95 100644 --- a/libchimara/chimara-if.c +++ b/libchimara/chimara-if.c @@ -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);