mirror of
https://github.com/libretro/RetroArch
synced 2025-03-24 22:43:41 +00:00
Cleanups
This commit is contained in:
parent
3aca3bceb9
commit
0bcbf5d972
16
cheats.c
16
cheats.c
@ -32,10 +32,10 @@
|
|||||||
|
|
||||||
void cheat_manager_apply_cheats(cheat_manager_t *handle)
|
void cheat_manager_apply_cheats(cheat_manager_t *handle)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i, idx = 0;
|
||||||
unsigned idx = 0;
|
|
||||||
|
|
||||||
pretro_cheat_reset();
|
pretro_cheat_reset();
|
||||||
|
|
||||||
for (i = 0; i < handle->size; i++)
|
for (i = 0; i < handle->size; i++)
|
||||||
{
|
{
|
||||||
if (handle->cheats[i].state)
|
if (handle->cheats[i].state)
|
||||||
@ -64,10 +64,7 @@ cheat_manager_t *cheat_manager_load(const char *path)
|
|||||||
|
|
||||||
for (i = 0; i < cheats; i++)
|
for (i = 0; i < cheats; i++)
|
||||||
{
|
{
|
||||||
char key[64];
|
char key[64], desc_key[256], code_key[256], enable_key[256];
|
||||||
char desc_key[256];
|
|
||||||
char code_key[256];
|
|
||||||
char enable_key[256];
|
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
bool tmp_bool = false;
|
bool tmp_bool = false;
|
||||||
|
|
||||||
@ -94,8 +91,9 @@ cheat_manager_t *cheat_manager_load(const char *path)
|
|||||||
cheat_manager_t *cheat_manager_new(unsigned size)
|
cheat_manager_t *cheat_manager_new(unsigned size)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
cheat_manager_t *handle = NULL;
|
cheat_manager_t *handle = (cheat_manager_t*)
|
||||||
handle = (cheat_manager_t*)calloc(1, sizeof(struct cheat_manager));
|
calloc(1, sizeof(struct cheat_manager));
|
||||||
|
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -176,6 +174,7 @@ void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx)
|
|||||||
{
|
{
|
||||||
msg_queue_clear(g_extern.msg_queue);
|
msg_queue_clear(g_extern.msg_queue);
|
||||||
char msg[256];
|
char msg[256];
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "Cheat: #%u [%s]: %s",
|
snprintf(msg, sizeof(msg), "Cheat: #%u [%s]: %s",
|
||||||
handle_idx, handle->cheats[handle_idx].state ? "ON" : "OFF",
|
handle_idx, handle->cheats[handle_idx].state ? "ON" : "OFF",
|
||||||
(handle->cheats[handle_idx].desc) ?
|
(handle->cheats[handle_idx].desc) ?
|
||||||
@ -200,6 +199,7 @@ void cheat_manager_index_next(cheat_manager_t *handle)
|
|||||||
{
|
{
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
handle->ptr = (handle->ptr + 1) % handle->size;
|
handle->ptr = (handle->ptr + 1) % handle->size;
|
||||||
cheat_manager_update(handle, handle->ptr);
|
cheat_manager_update(handle, handle->ptr);
|
||||||
}
|
}
|
||||||
|
20
content.c
20
content.c
@ -178,8 +178,14 @@ static ssize_t read_content_file(const char *path, void **buf)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt to save valuable RAM data somewhere. */
|
/**
|
||||||
|
* dump_to_file_desperate:
|
||||||
|
* @data : pointer to data buffer.
|
||||||
|
* @size : size of @data.
|
||||||
|
* @type : type of file to be saved.
|
||||||
|
*
|
||||||
|
* Attempt to save valuable RAM data somewhere.
|
||||||
|
**/
|
||||||
static void dump_to_file_desperate(const void *data,
|
static void dump_to_file_desperate(const void *data,
|
||||||
size_t size, unsigned type)
|
size_t size, unsigned type)
|
||||||
{
|
{
|
||||||
@ -629,19 +635,21 @@ bool init_content_file(void)
|
|||||||
/* Try to extract all content we're going to load if appropriate. */
|
/* Try to extract all content we're going to load if appropriate. */
|
||||||
for (i = 0; i < content->size; i++)
|
for (i = 0; i < content->size; i++)
|
||||||
{
|
{
|
||||||
|
const char *ext = NULL;
|
||||||
|
const char *valid_ext = NULL;
|
||||||
|
|
||||||
/* Block extract check. */
|
/* Block extract check. */
|
||||||
if (content->elems[i].attr.i & 1)
|
if (content->elems[i].attr.i & 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char *ext = path_get_extension(content->elems[i].data);
|
ext = path_get_extension(content->elems[i].data);
|
||||||
|
valid_ext = special ? special->roms[i].valid_extensions :
|
||||||
const char *valid_ext = special ?
|
|
||||||
special->roms[i].valid_extensions :
|
|
||||||
g_extern.system.info.valid_extensions;
|
g_extern.system.info.valid_extensions;
|
||||||
|
|
||||||
if (ext && !strcasecmp(ext, "zip"))
|
if (ext && !strcasecmp(ext, "zip"))
|
||||||
{
|
{
|
||||||
char temporary_content[PATH_MAX_LENGTH];
|
char temporary_content[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
strlcpy(temporary_content, content->elems[i].data,
|
strlcpy(temporary_content, content->elems[i].data,
|
||||||
sizeof(temporary_content));
|
sizeof(temporary_content));
|
||||||
|
|
||||||
|
23
core_info.c
23
core_info.c
@ -31,6 +31,7 @@ static void core_info_list_resolve_all_extensions(
|
|||||||
core_info_list_t *core_info_list)
|
core_info_list_t *core_info_list)
|
||||||
{
|
{
|
||||||
size_t i, all_ext_len = 0;
|
size_t i, all_ext_len = 0;
|
||||||
|
|
||||||
if (!core_info_list)
|
if (!core_info_list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -62,6 +63,7 @@ static void core_info_list_resolve_all_firmware(
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
unsigned c;
|
unsigned c;
|
||||||
|
|
||||||
if (!core_info_list)
|
if (!core_info_list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -104,6 +106,7 @@ core_info_list_t *core_info_list_new(const char *modules_path)
|
|||||||
core_info_list_t *core_info_list = NULL;
|
core_info_list_t *core_info_list = NULL;
|
||||||
struct string_list *contents = (struct string_list*)
|
struct string_list *contents = (struct string_list*)
|
||||||
dir_list_new(modules_path, EXT_EXECUTABLES, false);
|
dir_list_new(modules_path, EXT_EXECUTABLES, false);
|
||||||
|
|
||||||
if (!contents)
|
if (!contents)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -216,6 +219,7 @@ error:
|
|||||||
void core_info_list_free(core_info_list_t *core_info_list)
|
void core_info_list_free(core_info_list_t *core_info_list)
|
||||||
{
|
{
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
|
|
||||||
if (!core_info_list)
|
if (!core_info_list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -223,6 +227,9 @@ void core_info_list_free(core_info_list_t *core_info_list)
|
|||||||
{
|
{
|
||||||
core_info_t *info = (core_info_t*)&core_info_list->list[i];
|
core_info_t *info = (core_info_t*)&core_info_list->list[i];
|
||||||
|
|
||||||
|
if (!info)
|
||||||
|
continue;
|
||||||
|
|
||||||
free(info->path);
|
free(info->path);
|
||||||
free(info->systemname);
|
free(info->systemname);
|
||||||
free(info->system_manufacturer);
|
free(info->system_manufacturer);
|
||||||
@ -264,6 +271,7 @@ size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
|
|||||||
num = 0;
|
num = 0;
|
||||||
for (i = 0; i < core_info_list->count; i++)
|
for (i = 0; i < core_info_list->count; i++)
|
||||||
num += !!core_info_list->list[i].data;
|
num += !!core_info_list->list[i].data;
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,6 +279,7 @@ bool core_info_list_get_display_name(core_info_list_t *core_info_list,
|
|||||||
const char *path, char *buf, size_t size)
|
const char *path, char *buf, size_t size)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!core_info_list)
|
if (!core_info_list)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -385,13 +394,17 @@ static int core_info_qsort_cmp(const void *a_, const void *b_)
|
|||||||
void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
||||||
const char *path, const core_info_t **infos, size_t *num_infos)
|
const char *path, const core_info_t **infos, size_t *num_infos)
|
||||||
{
|
{
|
||||||
|
struct string_list *list = NULL;
|
||||||
|
size_t supported = 0, i;
|
||||||
|
|
||||||
if (!core_info_list)
|
if (!core_info_list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
(void)list;
|
||||||
|
|
||||||
core_info_tmp_path = path;
|
core_info_tmp_path = path;
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
struct string_list *list = NULL;
|
|
||||||
if (!strcasecmp(path_get_extension(path), "zip"))
|
if (!strcasecmp(path_get_extension(path), "zip"))
|
||||||
list = zlib_get_file_list(path);
|
list = zlib_get_file_list(path);
|
||||||
core_info_tmp_list = list;
|
core_info_tmp_list = list;
|
||||||
@ -402,11 +415,13 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
|||||||
qsort(core_info_list->list, core_info_list->count,
|
qsort(core_info_list->list, core_info_list->count,
|
||||||
sizeof(core_info_t), core_info_qsort_cmp);
|
sizeof(core_info_t), core_info_qsort_cmp);
|
||||||
|
|
||||||
size_t supported, i;
|
|
||||||
supported = 0;
|
|
||||||
for (i = 0; i < core_info_list->count; i++, supported++)
|
for (i = 0; i < core_info_list->count; i++, supported++)
|
||||||
{
|
{
|
||||||
const core_info_t *core = &core_info_list->list[i];
|
const core_info_t *core = &core_info_list->list[i];
|
||||||
|
|
||||||
|
if (!core)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!core_info_does_support_file(core, path)
|
if (!core_info_does_support_file(core, path)
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
&& !core_info_does_support_any_file(core, list)
|
&& !core_info_does_support_any_file(core, list)
|
||||||
@ -432,7 +447,7 @@ static core_info_t *find_core_info(core_info_list_t *list,
|
|||||||
for (i = 0; i < list->count; i++)
|
for (i = 0; i < list->count; i++)
|
||||||
{
|
{
|
||||||
core_info_t *info = (core_info_t*)&list->list[i];
|
core_info_t *info = (core_info_t*)&list->list[i];
|
||||||
if (info->path && !strcmp(info->path, core))
|
if (info && info->path && !strcmp(info->path, core))
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user