Ejemplo n.º 1
0
int cheevos_load( const char* json )
{
  static const jsonsax_handlers_t handlers =
  {
    NULL,
    NULL,
    NULL,
    read__json_end_object,
    NULL,
    read__json_end_array,
    read__json_key,
    NULL,
    read__json_string,
    read__json_number,
    NULL,
    NULL
  };

  /* Count the number of achievements in the JSON file. */

  unsigned core_count, unofficial_count;

  if ( count_cheevos( json, &core_count, &unofficial_count ) != JSONSAX_OK )
  {
    return -1;
  }

  /* Allocate the achievements. */

  core_cheevos.cheevos = (cheevo_t*)malloc( core_count * sizeof( cheevo_t ) );
  core_cheevos.count = core_count;

  unofficial_cheevos.cheevos = (cheevo_t*)malloc( unofficial_count * sizeof( cheevo_t ) );
  unofficial_cheevos.count = unofficial_count;

  if ( !core_cheevos.cheevos || !unofficial_cheevos.cheevos )
  {
    free( (void*)core_cheevos.cheevos );
    free( (void*)unofficial_cheevos.cheevos );

    return -1;
  }

  /* Load the achievements. */

  cheevos_readud_t ud;
  ud.in_cheevos = 0;
  ud.field = NULL;
  ud.core_count = 0;
  ud.unofficial_count = 0;

  if ( jsonsax_parse( json, &handlers, (void*)&ud ) == JSONSAX_OK )
  {
    return 0;
  }

  cheevos_unload();
  return -1;
}
Ejemplo n.º 2
0
static void event_deinit_core(bool reinit)
{
#ifdef HAVE_CHEEVOS
   /* Unload the achievements from memory. */
   cheevos_unload();
#endif

   event_deinit_core_interfaces();
   core.retro_unload_game();
   core.retro_deinit();

   if (reinit)
      event_command(EVENT_CMD_DRIVERS_DEINIT);

   /* auto overrides: reload the original config */
   if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL))
   {
      config_unload_override();
      runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
   }

   uninit_libretro_sym();
}
Ejemplo n.º 3
0
static void event_deinit_core(bool reinit)
{
   global_t *global     = global_get_ptr();

#ifdef HAVE_CHEEVOS
   /* Unload the achievements from memory. */
   cheevos_unload();
#endif

   core.retro_unload_game();
   core.retro_deinit();

   if (reinit)
      event_command(EVENT_CMD_DRIVERS_DEINIT);

  /* auto overrides: reload the original config */
   if(global->overrides_active)
   {
      config_unload_override();
      global->overrides_active = false;
   }

   uninit_libretro_sym();
}
Ejemplo n.º 4
0
static int cheevos_parse(const char *json)
{
   static const jsonsax_handlers_t handlers =
   {
      NULL,
      NULL,
      NULL,
      cheevos_read__json_end_object,
      NULL,
      cheevos_read__json_end_array,
      cheevos_read__json_key,
      NULL,
      cheevos_read__json_string,
      cheevos_read__json_number,
      NULL,
      NULL
   };

   static int initialize = 1;

   unsigned core_count, unofficial_count;
   cheevos_readud_t ud;
   settings_t *settings         = config_get_ptr();

   /* Just return OK if cheevos are disabled. */
   if (!settings->cheevos.enable)
      return 0;

   /* Count the number of achievements in the JSON file. */

   if (cheevos_count_cheevos(json, &core_count, &unofficial_count) != JSONSAX_OK)
      return -1;

   /* Allocate the achievements. */

   cheevos_locals.core.cheevos = (cheevo_t*)malloc(core_count * sizeof(cheevo_t));
   cheevos_locals.core.count = core_count;

   cheevos_locals.unofficial.cheevos = (cheevo_t*)malloc(unofficial_count * sizeof(cheevo_t));
   cheevos_locals.unofficial.count = unofficial_count;

   if (!cheevos_locals.core.cheevos || !cheevos_locals.unofficial.cheevos)
   {
      free((void*)cheevos_locals.core.cheevos);
      free((void*)cheevos_locals.unofficial.cheevos);
      cheevos_locals.core.count = cheevos_locals.unofficial.count = 0;

      return -1;
   }

   memset((void*)cheevos_locals.core.cheevos, 0, core_count * sizeof(cheevo_t));
   memset((void*)cheevos_locals.unofficial.cheevos, 0, unofficial_count * sizeof(cheevo_t));

   /* Load the achievements. */

   ud.in_cheevos = 0;
   ud.field = NULL;
   ud.core_count = 0;
   ud.unofficial_count = 0;

   if (!jsonsax_parse(json, &handlers, (void*)&ud) == JSONSAX_OK)
   {
      cheevos_unload();
      return -1;
   }
   
   if (initialize)
   {
      initialize = 0;
      cheevos_locals.jobs = async_job_new();
   }

   return -(cheevos_locals.jobs == NULL);
}