Exemple #1
0
/**
 * load_content:
 * @special          : subsystem of content to be loaded. Can be NULL.
 * content           :
 *
 * Load content file (for libretro core).
 *
 * Returns : true if successful, otherwise false.
 **/
static bool load_content(const struct retro_subsystem_info *special,
      const struct string_list *content)
{
   unsigned i;
   bool ret = true;
   const char* json = NULL;
   struct string_list* additional_path_allocs = string_list_new();
   struct retro_game_info *info = (struct retro_game_info*)
      calloc(content->size, sizeof(*info));

   if (!info)
   {
      string_list_free(additional_path_allocs);
      return false;
   }

   for (i = 0; i < content->size; i++)
   {
      const char *path     = content->elems[i].data;
      int         attr     = content->elems[i].attr.i;
      bool need_fullpath   = attr & 2;
      bool require_content = attr & 4;

      if (require_content && !*path)
      {
         RARCH_LOG("libretro core requires content, but nothing was provided.\n");
         ret = false;
         goto end;
      }

      info[i].path = NULL;

      if (*path)
         info[i].path = path;

      if (!need_fullpath && *path)
      {
         if (!load_content_dont_need_fullpath(&info[i], i, path))
            goto end;
      }
      else
      {
         RARCH_LOG("Content loading skipped. Implementation will"
               " load it on its own.\n");

         if (!load_content_need_fullpath(&info[i], i,
                  additional_path_allocs, need_fullpath, path))
            goto end;
      }
   }

   if (special)
      ret = core.retro_load_game_special(special->id, info, content->size);
   else
   {
      if (*content->elems[0].data)
      {
         if ( cheevos_get_by_content(&json, info->data, info->size) == 0 )
         {
            cheevos_load(json);
            free((void*)json);
         }
      }

      ret = core.retro_load_game(*content->elems[0].data ? info : NULL);
   }

   if (!ret)
      RARCH_ERR("%s.\n", msg_hash_to_str(MSG_FAILED_TO_LOAD_CONTENT));

end:
   for (i = 0; i < content->size; i++)
      free((void*)info[i].data);

   string_list_free(additional_path_allocs);
   if (info)
      free(info);
   return ret;
}
Exemple #2
0
/**
 * load_content:
 * @special          : subsystem of content to be loaded. Can be NULL.
 * content           :
 *
 * Load content file (for libretro core).
 *
 * Returns : true if successful, otherwise false.
 **/
static bool load_content(const struct retro_subsystem_info *special,
      const struct string_list *content)
{
   unsigned i;
   bool ret = true;
   struct string_list* additional_path_allocs = string_list_new();
   struct retro_game_info *info = (struct retro_game_info*)
      calloc(content->size, sizeof(*info));

   if (!info)
   {
      string_list_free(additional_path_allocs);
      return false;
   }

   for (i = 0; i < content->size; i++)
   {
      const char *path     = content->elems[i].data;
      int         attr     = content->elems[i].attr.i;
      bool need_fullpath   = attr & 2;
      bool require_content = attr & 4;

      if (require_content && !*path)
      {
         RARCH_LOG("libretro core requires content, but nothing was provided.\n");
         ret = false;
         goto end;
      }

      info[i].path = NULL;

      if (*path)
         info[i].path = path;

      if (!need_fullpath && *path)
      {
         if (!load_content_dont_need_fullpath(&info[i], i, path))
            goto end;
      }
      else
      {
         RARCH_LOG("Content loading skipped. Implementation will"
               " load it on its own.\n");

         if (!load_content_need_fullpath(&info[i], i,
                  additional_path_allocs, need_fullpath, path))
            goto end;
      }
   }

   if (special)
      ret = core.retro_load_game_special(special->id, info, content->size);
   else
   {
      ret = core.retro_load_game(*content->elems[0].data ? info : NULL);
      
#ifdef HAVE_CHEEVOS
      /* Load the achievements into memory if the game has content. */

      cheevos_globals.cheats_were_enabled = cheevos_globals.cheats_are_enabled;
      cheevos_load(*content->elems[0].data ? info : NULL);
#endif
   }

   if (!ret)
      RARCH_ERR("%s.\n", msg_hash_to_str(MSG_FAILED_TO_LOAD_CONTENT));

end:
   for (i = 0; i < content->size; i++)
      free((void*)info[i].data);

   string_list_free(additional_path_allocs);
   if (info)
      free(info);
   return ret;
}