mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
(cheats.c) Declare variables at top
This commit is contained in:
parent
7773daa125
commit
25e0f88e17
47
cheats.c
47
cheats.c
@ -73,20 +73,20 @@ static char *strcat_alloc(char *dest, const char *input)
|
|||||||
|
|
||||||
static bool xml_grab_cheat(struct cheat *cht, xmlNodePtr ptr)
|
static bool xml_grab_cheat(struct cheat *cht, xmlNodePtr ptr)
|
||||||
{
|
{
|
||||||
|
bool first;
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
memset(cht, 0, sizeof(struct cheat));
|
memset(cht, 0, sizeof(struct cheat));
|
||||||
bool first = true;
|
first = true;
|
||||||
|
|
||||||
for (; ptr; ptr = ptr->next)
|
for (; ptr; ptr = ptr->next)
|
||||||
{
|
{
|
||||||
if (strcmp((const char*)ptr->name, "description") == 0)
|
if (strcmp((const char*)ptr->name, "description") == 0)
|
||||||
{
|
|
||||||
cht->desc = (char*)xmlNodeGetContent(ptr);
|
cht->desc = (char*)xmlNodeGetContent(ptr);
|
||||||
}
|
|
||||||
else if (strcmp((const char*)ptr->name, "code") == 0)
|
else if (strcmp((const char*)ptr->name, "code") == 0)
|
||||||
{
|
{
|
||||||
|
xmlChar *code;
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
cht->code = strcat_alloc(cht->code, "+");
|
cht->code = strcat_alloc(cht->code, "+");
|
||||||
@ -94,7 +94,7 @@ static bool xml_grab_cheat(struct cheat *cht, xmlNodePtr ptr)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlChar *code = xmlNodeGetContent(ptr);
|
code = (xmlChar*)xmlNodeGetContent(ptr);
|
||||||
if (!code)
|
if (!code)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ static bool xml_grab_cheats(cheat_manager_t *handle, xmlNodePtr ptr)
|
|||||||
{
|
{
|
||||||
if (strcmp((const char*)ptr->name, "name") == 0)
|
if (strcmp((const char*)ptr->name, "name") == 0)
|
||||||
{
|
{
|
||||||
xmlChar *name = xmlNodeGetContent(ptr);
|
xmlChar *name = (xmlChar*)xmlNodeGetContent(ptr);
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Found cheat for game: \"%s\"\n", name);
|
RARCH_LOG("Found cheat for game: \"%s\"\n", name);
|
||||||
@ -155,22 +155,27 @@ static void cheat_manager_apply_cheats(cheat_manager_t *handle)
|
|||||||
|
|
||||||
static void cheat_manager_load_config(cheat_manager_t *handle, const char *path, const char *sha256)
|
static void cheat_manager_load_config(cheat_manager_t *handle, const char *path, const char *sha256)
|
||||||
{
|
{
|
||||||
|
const char *num;
|
||||||
|
char *str, *save;
|
||||||
|
config_file_t *conf;
|
||||||
|
|
||||||
if (!(*path))
|
if (!(*path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
config_file_t *conf = config_file_new(path);
|
conf = (config_file_t*)config_file_new(path);
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char *str = NULL;
|
str = NULL;
|
||||||
if (!config_get_string(conf, sha256, &str))
|
if (!config_get_string(conf, sha256, &str))
|
||||||
{
|
{
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *save = NULL;
|
save = NULL;
|
||||||
const char *num = strtok_r(str, ";", &save);
|
num = (const char*)strtok_r(str, ";", &save);
|
||||||
|
|
||||||
while (num)
|
while (num)
|
||||||
{
|
{
|
||||||
unsigned index = strtoul(num, NULL, 0);
|
unsigned index = strtoul(num, NULL, 0);
|
||||||
@ -188,6 +193,10 @@ static void cheat_manager_load_config(cheat_manager_t *handle, const char *path,
|
|||||||
|
|
||||||
static void cheat_manager_save_config(cheat_manager_t *handle, const char *path, const char *sha256)
|
static void cheat_manager_save_config(cheat_manager_t *handle, const char *path, const char *sha256)
|
||||||
{
|
{
|
||||||
|
unsigned i;
|
||||||
|
char conf_str[512] = {0};
|
||||||
|
char tmp[32] = {0};
|
||||||
|
|
||||||
if (!(*path))
|
if (!(*path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -201,10 +210,6 @@ static void cheat_manager_save_config(cheat_manager_t *handle, const char *path,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned i;
|
|
||||||
char conf_str[512] = {0};
|
|
||||||
char tmp[32] = {0};
|
|
||||||
|
|
||||||
for (i = 0; i < handle->size; i++)
|
for (i = 0; i < handle->size; i++)
|
||||||
{
|
{
|
||||||
if (handle->cheats[i].state)
|
if (handle->cheats[i].state)
|
||||||
@ -227,18 +232,23 @@ static void cheat_manager_save_config(cheat_manager_t *handle, const char *path,
|
|||||||
|
|
||||||
cheat_manager_t *cheat_manager_new(const char *path)
|
cheat_manager_t *cheat_manager_new(const char *path)
|
||||||
{
|
{
|
||||||
|
xmlParserCtxtPtr ctx;
|
||||||
|
xmlNodePtr head, cur;
|
||||||
|
xmlDocPtr doc;
|
||||||
|
cheat_manager_t *handle;
|
||||||
|
|
||||||
LIBXML_TEST_VERSION;
|
LIBXML_TEST_VERSION;
|
||||||
|
|
||||||
pretro_cheat_reset();
|
pretro_cheat_reset();
|
||||||
|
|
||||||
xmlParserCtxtPtr ctx = NULL;
|
ctx = NULL;
|
||||||
xmlDocPtr doc = NULL;
|
doc = NULL;
|
||||||
cheat_manager_t *handle = (cheat_manager_t*)calloc(1, sizeof(struct cheat_manager));
|
handle = (cheat_manager_t*)calloc(1, sizeof(struct cheat_manager));
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
xmlNodePtr head = NULL;
|
head = NULL;
|
||||||
xmlNodePtr cur = NULL;
|
cur = NULL;
|
||||||
|
|
||||||
handle->buf_size = 1;
|
handle->buf_size = 1;
|
||||||
handle->cheats = (struct cheat*)calloc(handle->buf_size, sizeof(struct cheat));
|
handle->cheats = (struct cheat*)calloc(handle->buf_size, sizeof(struct cheat));
|
||||||
@ -381,4 +391,3 @@ void cheat_manager_index_prev(cheat_manager_t *handle)
|
|||||||
|
|
||||||
cheat_manager_update(handle);
|
cheat_manager_update(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user