mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
undefined debug macros
This commit is contained in:
parent
fad2acf1ee
commit
d791da9507
146
cheevos.c
146
cheevos.c
@ -19,7 +19,6 @@
|
||||
#include <formats/jsonsax.h>
|
||||
#include <streams/file_stream.h>
|
||||
#include <rhash.h>
|
||||
#include <rthreads/async_job.h>
|
||||
#include <libretro.h>
|
||||
|
||||
#include "cheevos.h"
|
||||
@ -28,6 +27,7 @@
|
||||
#include "libretro.h"
|
||||
#include "system.h"
|
||||
#include "network/net_http_special.h"
|
||||
#include "tasks/tasks_internal.h"
|
||||
#include "configuration.h"
|
||||
#include "performance_counters.h"
|
||||
#include "msg_hash.h"
|
||||
@ -41,8 +41,8 @@
|
||||
|
||||
#include "verbosity.h"
|
||||
|
||||
/* Define this macro to deactivate awarded cheevos. */
|
||||
#undef CHEEVOS_DEACTIVATE
|
||||
/* Define this macro to prevent cheevos from being deactivated. */
|
||||
#undef CHEEVOS_DONT_DEACTIVATE
|
||||
|
||||
/* Define this macro to log URLs (will log the user token). */
|
||||
#undef CHEEVOS_LOG_URLS
|
||||
@ -50,6 +50,9 @@
|
||||
/* Define this macro to dump all cheevos' addresses. */
|
||||
#undef CHEEVOS_DUMP_ADDRS
|
||||
|
||||
/* Define this macro to remove HTTP timeouts. */
|
||||
#undef CHEEVOS_NO_TIMEOUT
|
||||
|
||||
#define JSON_KEY_GAMEID 0xb4960eecU
|
||||
#define JSON_KEY_ACHIEVEMENTS 0x69749ae1U
|
||||
#define JSON_KEY_ID 0x005973f2U
|
||||
@ -276,10 +279,6 @@ static cheevos_locals_t cheevos_locals =
|
||||
static int cheats_are_enabled = 0;
|
||||
static int cheats_were_enabled = 0;
|
||||
|
||||
/* forward declaration */
|
||||
|
||||
int retroarch_async_job_add(async_task_t task, void *payload);
|
||||
|
||||
/*****************************************************************************
|
||||
Supporting functions.
|
||||
*****************************************************************************/
|
||||
@ -300,7 +299,12 @@ static int cheevos_http_get(const char **result, size_t *size,
|
||||
const char *url, retro_time_t *timeout)
|
||||
{
|
||||
const char *msg = NULL;
|
||||
|
||||
#ifdef CHEEVOS_NO_TIMEOUT
|
||||
int ret = net_http_get(result, size, url, NULL);
|
||||
#else
|
||||
int ret = net_http_get(result, size, url, timeout);
|
||||
#endif
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
@ -1424,38 +1428,39 @@ static int cheevos_login(retro_time_t *timeout)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void cheevos_unlocker(void *payload)
|
||||
static void cheevos_make_unlock_url(const cheevo_t *cheevo, char* url, size_t url_size)
|
||||
{
|
||||
char request[256];
|
||||
const char *result;
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned cheevo_id = (unsigned)(uintptr_t)payload;
|
||||
|
||||
if (!cheevos_login(NULL))
|
||||
{
|
||||
snprintf(
|
||||
request, sizeof(request),
|
||||
"http://retroachievements.org/dorequest.php?r=awardachievement&u=%s&t=%s&a=%u&h=%d",
|
||||
settings->cheevos.username, cheevos_locals.token, cheevo_id, settings->cheevos.hardcore_mode_enable
|
||||
);
|
||||
snprintf(
|
||||
url, url_size,
|
||||
"http://retroachievements.org/dorequest.php?r=awardachievement&u=%s&t=%s&a=%u&h=%d",
|
||||
settings->cheevos.username, cheevos_locals.token, cheevo->id, settings->cheevos.hardcore_mode_enable
|
||||
);
|
||||
|
||||
url[url_size - 1] = 0;
|
||||
|
||||
request[sizeof(request) - 1] = 0;
|
||||
|
||||
#ifdef CHEEVOS_LOG_URLS
|
||||
RARCH_LOG("CHEEVOS url to award the cheevo: %s\n", request);
|
||||
RARCH_LOG("CHEEVOS url to award the cheevo: %s\n", url);
|
||||
#endif
|
||||
|
||||
if (!cheevos_http_get(&result, NULL, request, NULL))
|
||||
{
|
||||
RARCH_LOG("CHEEVOS awarded achievement %u: %s\n", cheevo_id, result);
|
||||
free((void*)result);
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_ERR("CHEEVOS error awarding achievement %u, will retry...\n", cheevo_id);
|
||||
/* re-schedule */
|
||||
retroarch_async_job_add(cheevos_unlocker, (void*)(uintptr_t)cheevo_id);
|
||||
}
|
||||
}
|
||||
|
||||
static void cheevos_unlocked(void *task_data, void *user_data, const char *error)
|
||||
{
|
||||
cheevo_t *cheevo = (cheevo_t *)user_data;
|
||||
|
||||
if (error == NULL)
|
||||
{
|
||||
RARCH_LOG("CHEEVOS awarded achievement %u\n", cheevo->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
char url[256];
|
||||
|
||||
RARCH_ERR("CHEEVOS error awarding achievement %u, retrying\n", cheevo->id);
|
||||
|
||||
cheevos_make_unlock_url(cheevo, url, sizeof(url));
|
||||
rarch_task_push_http_transfer(url, true, NULL, cheevos_unlocked, cheevo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1468,15 +1473,18 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set)
|
||||
{
|
||||
if (cheevo->active && cheevos_test_cheevo(cheevo))
|
||||
{
|
||||
RARCH_LOG("CHEEVOS awarding cheevo %s (%s)\n", cheevo->title, cheevo->description);
|
||||
settings_t *settings = config_get_ptr();
|
||||
char url[256];
|
||||
|
||||
cheevo->active = 0;
|
||||
|
||||
RARCH_LOG("CHEEVOS awarding cheevo %u: %s (%s)\n", cheevo->id, cheevo->title, cheevo->description);
|
||||
|
||||
runloop_msg_queue_push(cheevo->title, 0, 3 * 60, false);
|
||||
runloop_msg_queue_push(cheevo->description, 0, 5 * 60, false);
|
||||
|
||||
retroarch_async_job_add(cheevos_unlocker,
|
||||
(void*)(uintptr_t)cheevo->id);
|
||||
|
||||
cheevo->active = 0;
|
||||
cheevos_make_unlock_url(cheevo, url, sizeof(url));
|
||||
rarch_task_push_http_transfer(url, true, NULL, cheevos_unlocked, cheevo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1598,43 +1606,43 @@ static unsigned cheevos_get_game_id(unsigned char *hash, retro_time_t *timeout)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cheevos_playing(void *payload)
|
||||
static void cheevos_make_playing_url(unsigned game_id, char* url, size_t url_size)
|
||||
{
|
||||
char request[256];
|
||||
const char* json;
|
||||
unsigned game_id = (unsigned)(uintptr_t)payload;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!cheevos_login(NULL))
|
||||
{
|
||||
snprintf(
|
||||
request, sizeof(request),
|
||||
"http://retroachievements.org/dorequest.php?r=postactivity&u=%s&t=%s&a=3&m=%u",
|
||||
settings->cheevos.username, cheevos_locals.token, game_id
|
||||
);
|
||||
|
||||
request[sizeof(request) - 1] = 0;
|
||||
|
||||
snprintf(
|
||||
url, url_size,
|
||||
"http://retroachievements.org/dorequest.php?r=postactivity&u=%s&t=%s&a=3&m=%u",
|
||||
settings->cheevos.username, cheevos_locals.token, game_id
|
||||
);
|
||||
|
||||
url[url_size - 1] = 0;
|
||||
|
||||
#ifdef CHEEVOS_LOG_URLS
|
||||
RARCH_LOG("CHEEVOS url to post the 'playing' activity: %s\n", request);
|
||||
RARCH_LOG("CHEEVOS url to post the 'playing' activity: %s\n", url);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!cheevos_http_get(&json, NULL, request, NULL))
|
||||
{
|
||||
free((void*)json);
|
||||
RARCH_LOG("CHEEVOS posted playing game %u activity\n", game_id);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_ERR("CHEEVOS error posting playing game %u activity, will retry\n", game_id);
|
||||
/* re-schedule */
|
||||
retroarch_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id);
|
||||
}
|
||||
static void cheevos_playing(void *task_data, void *user_data, const char *error)
|
||||
{
|
||||
unsigned game_id = (unsigned)(uintptr_t)user_data;
|
||||
|
||||
if (error == NULL)
|
||||
{
|
||||
RARCH_LOG("CHEEVOS posted playing game %u activity\n", game_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
char url[256];
|
||||
|
||||
RARCH_ERR("CHEEVOS error posting playing game %u activity, will retry\n", game_id);
|
||||
|
||||
cheevos_make_playing_url(game_id, url, sizeof(url));
|
||||
rarch_task_push_http_transfer(url, true, NULL, cheevos_playing, (void*)(uintptr_t)game_id);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CHEEVOS_DEACTIVATE
|
||||
#ifndef CHEEVOS_DONT_DEACTIVATE
|
||||
static int cheevos_deactivate__json_index(void *userdata, unsigned int index)
|
||||
{
|
||||
cheevos_deactivate_t *ud = (cheevos_deactivate_t*)userdata;
|
||||
@ -1697,7 +1705,7 @@ static int cheevos_deactivate_unlocks(unsigned game_id, retro_time_t *timeout)
|
||||
{
|
||||
/* Only call this function after the cheevos have been loaded. */
|
||||
|
||||
#ifdef CHEEVOS_DEACTIVATE
|
||||
#ifndef CHEEVOS_DONT_DEACTIVATE
|
||||
static const jsonsax_handlers_t handlers =
|
||||
{
|
||||
NULL,
|
||||
@ -2061,6 +2069,7 @@ bool cheevos_load(const void *data)
|
||||
const char *json = NULL;
|
||||
retro_time_t timeout = 5000000;
|
||||
unsigned game_id = 0;
|
||||
char url[256];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_game_info *info = (const struct retro_game_info*)data;
|
||||
|
||||
@ -2156,7 +2165,8 @@ bool cheevos_load(const void *data)
|
||||
free((void*)json);
|
||||
cheevos_locals.loaded = 1;
|
||||
|
||||
retroarch_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id);
|
||||
cheevos_make_playing_url(game_id, url, sizeof(url));
|
||||
rarch_task_push_http_transfer(url, true, NULL, cheevos_playing, (void*)(uintptr_t)game_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,9 @@ struct retro_task
|
||||
* to signal the task *must* end. */
|
||||
bool cancelled;
|
||||
|
||||
/* if true no OSD messages will be displayed. */
|
||||
bool mute;
|
||||
|
||||
/* created by the handler, destroyed by the user */
|
||||
void *task_data;
|
||||
|
||||
|
@ -1515,7 +1515,7 @@ static int action_ok_download_generic(const char *path,
|
||||
transf->type_hash = menu_hash_calculate(type_msg);
|
||||
strlcpy(transf->path, path, sizeof(transf->path));
|
||||
|
||||
rarch_task_push_http_transfer(s3, type_msg, cb_generic_download, transf);
|
||||
rarch_task_push_http_transfer(s3, false, type_msg, cb_generic_download, transf);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -1777,7 +1777,7 @@ static int generic_action_ok_network(const char *path,
|
||||
#endif
|
||||
}
|
||||
|
||||
rarch_task_push_http_transfer(url_path, url_label, callback, NULL);
|
||||
rarch_task_push_http_transfer(url_path, false, url_label, callback, NULL);
|
||||
|
||||
return generic_action_ok_displaylist_push(path,
|
||||
label, type, idx, entry_idx, type_id2);
|
||||
|
21
retroarch.c
21
retroarch.c
@ -26,9 +26,6 @@
|
||||
#include <boolean.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <lists/string_list.h>
|
||||
#ifdef HAVE_THREADS
|
||||
#include <rthreads/async_job.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _XBOX
|
||||
@ -115,10 +112,6 @@ static char current_savefile_dir[PATH_MAX_LENGTH];
|
||||
static char error_string[PATH_MAX_LENGTH];
|
||||
static jmp_buf error_sjlj_context;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
static async_job_t *async_jobs;
|
||||
#endif
|
||||
|
||||
#define _PSUPP(var, name, desc) printf(" %s:\n\t\t%s: %s\n", name, desc, _##var##_supp ? "yes" : "no")
|
||||
|
||||
static void retroarch_print_features(void)
|
||||
@ -178,13 +171,6 @@ static void retroarch_print_features(void)
|
||||
}
|
||||
#undef _PSUPP
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
int retroarch_async_job_add(async_task_t task, void *payload)
|
||||
{
|
||||
return async_job_add(async_jobs, task, payload);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void retroarch_print_version(void)
|
||||
{
|
||||
char str[PATH_MAX_LENGTH] = {0};
|
||||
@ -1462,10 +1448,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL);
|
||||
|
||||
rarch_ctl(RARCH_CTL_UNSET_INITED, NULL);
|
||||
#ifdef HAVE_THREADS
|
||||
async_job_free(async_jobs);
|
||||
async_jobs = NULL;
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CTL_INIT:
|
||||
rarch_ctl(RARCH_CTL_DEINIT, NULL);
|
||||
@ -1476,9 +1458,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
|
||||
}
|
||||
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_INIT, NULL);
|
||||
#ifdef HAVE_THREADS
|
||||
async_jobs = async_job_new();
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CTL_SET_PATHS_REDIRECT:
|
||||
if(settings->sort_savestates_enable || settings->sort_savefiles_enable)
|
||||
|
@ -232,7 +232,7 @@ static bool rarch_task_http_retriever(retro_task_t *task, void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
void *rarch_task_push_http_transfer(const char *url, const char *type,
|
||||
void *rarch_task_push_http_transfer(const char *url, bool mute, const char *type,
|
||||
retro_task_callback_t cb, void *user_data)
|
||||
{
|
||||
char tmp[PATH_MAX_LENGTH];
|
||||
@ -280,6 +280,7 @@ void *rarch_task_push_http_transfer(const char *url, const char *type,
|
||||
|
||||
t->handler = rarch_task_http_transfer_handler;
|
||||
t->state = http;
|
||||
t->mute = mute;
|
||||
t->callback = cb;
|
||||
t->user_data = user_data;
|
||||
t->progress = -1;
|
||||
|
@ -37,7 +37,7 @@ static void task_queue_msg_push(unsigned prio, unsigned duration,
|
||||
|
||||
void task_queue_push_progress(retro_task_t *task)
|
||||
{
|
||||
if (task->title)
|
||||
if (task->title && !task->mute)
|
||||
{
|
||||
if (task->finished)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ typedef struct nbio_handle
|
||||
} nbio_handle_t;
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
void *rarch_task_push_http_transfer(const char *url, const char *type,
|
||||
void *rarch_task_push_http_transfer(const char *url, bool mute, const char *type,
|
||||
retro_task_callback_t cb, void *userdata);
|
||||
|
||||
task_retriever_info_t *http_task_get_transfer_list(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user