(cheats.c) Cleanup
This commit is contained in:
parent
a10cdfa8b1
commit
c324e6ae97
29
cheats.c
29
cheats.c
|
@ -59,10 +59,10 @@ bool cheat_manager_save(cheat_manager_t *handle, const char *path)
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char buf[PATH_MAX_LENGTH];
|
config_file_t *conf = NULL;
|
||||||
char cheats_file[PATH_MAX_LENGTH];
|
char buf[PATH_MAX_LENGTH] = {0};
|
||||||
config_file_t *conf = NULL;
|
char cheats_file[PATH_MAX_LENGTH] = {0};
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
fill_pathname_join(buf, settings->cheat_database,
|
fill_pathname_join(buf, settings->cheat_database,
|
||||||
path, sizeof(buf));
|
path, sizeof(buf));
|
||||||
|
@ -87,7 +87,10 @@ bool cheat_manager_save(cheat_manager_t *handle, const char *path)
|
||||||
|
|
||||||
for (i = 0; i < handle->size; i++)
|
for (i = 0; i < handle->size; i++)
|
||||||
{
|
{
|
||||||
char key[64], desc_key[256], code_key[256], enable_key[256];
|
char key[64] = {0};
|
||||||
|
char desc_key[256] = {0};
|
||||||
|
char code_key[256] = {0};
|
||||||
|
char enable_key[256] = {0};
|
||||||
|
|
||||||
snprintf(key, sizeof(key), "cheat%u", i);
|
snprintf(key, sizeof(key), "cheat%u", i);
|
||||||
snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i);
|
snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i);
|
||||||
|
@ -129,9 +132,12 @@ cheat_manager_t *cheat_manager_load(const char *path)
|
||||||
|
|
||||||
for (i = 0; i < cheats; i++)
|
for (i = 0; i < cheats; i++)
|
||||||
{
|
{
|
||||||
char key[64], desc_key[256], code_key[256], enable_key[256];
|
char key[64] = {0};
|
||||||
char *tmp = NULL;
|
char desc_key[256] = {0};
|
||||||
bool tmp_bool = false;
|
char code_key[256] = {0};
|
||||||
|
char enable_key[256] = {0};
|
||||||
|
char *tmp = NULL;
|
||||||
|
bool tmp_bool = false;
|
||||||
|
|
||||||
snprintf(key, sizeof(key), "cheat%u", i);
|
snprintf(key, sizeof(key), "cheat%u", i);
|
||||||
snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i);
|
snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i);
|
||||||
|
@ -162,8 +168,9 @@ cheat_manager_t *cheat_manager_new(unsigned size)
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
handle->buf_size = handle->size = size;
|
handle->buf_size = size;
|
||||||
handle->cheats = (struct item_cheat*)
|
handle->size = size;
|
||||||
|
handle->cheats = (struct item_cheat*)
|
||||||
calloc(handle->buf_size, sizeof(struct item_cheat));
|
calloc(handle->buf_size, sizeof(struct item_cheat));
|
||||||
|
|
||||||
if (!handle->cheats)
|
if (!handle->cheats)
|
||||||
|
@ -240,7 +247,7 @@ void cheat_manager_free(cheat_manager_t *handle)
|
||||||
|
|
||||||
void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx)
|
void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx)
|
||||||
{
|
{
|
||||||
char msg[256];
|
char msg[256] = {0};
|
||||||
|
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -229,8 +229,10 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf,
|
||||||
{
|
{
|
||||||
if (new_poll.buttons[j] && !old_poll.buttons[j])
|
if (new_poll.buttons[j] && !old_poll.buttons[j])
|
||||||
{
|
{
|
||||||
|
char key[64] = {0};
|
||||||
|
|
||||||
fprintf(stderr, "\tJoybutton pressed: %d\n", j);
|
fprintf(stderr, "\tJoybutton pressed: %d\n", j);
|
||||||
char key[64];
|
|
||||||
snprintf(key, sizeof(key), "%s_%s_btn",
|
snprintf(key, sizeof(key), "%s_%s_btn",
|
||||||
input_config_get_prefix(player_index,
|
input_config_get_prefix(player_index,
|
||||||
input_config_bind_map[i].meta),
|
input_config_bind_map[i].meta),
|
||||||
|
@ -280,15 +282,16 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf,
|
||||||
|
|
||||||
if (abs(value) > 20000)
|
if (abs(value) > 20000)
|
||||||
{
|
{
|
||||||
|
char buf[8] = {0};
|
||||||
|
char key[64] = {0};
|
||||||
|
|
||||||
last_axis = j;
|
last_axis = j;
|
||||||
fprintf(stderr, "\tJoyaxis moved: Axis %d, Value %d\n",
|
fprintf(stderr, "\tJoyaxis moved: Axis %d, Value %d\n",
|
||||||
j, value);
|
j, value);
|
||||||
|
|
||||||
char buf[8];
|
|
||||||
snprintf(buf, sizeof(buf),
|
snprintf(buf, sizeof(buf),
|
||||||
value > 0 ? "+%d" : "-%d", j);
|
value > 0 ? "+%d" : "-%d", j);
|
||||||
|
|
||||||
char key[64];
|
|
||||||
snprintf(key, sizeof(key), "%s_%s_axis",
|
snprintf(key, sizeof(key), "%s_%s_axis",
|
||||||
input_config_get_prefix(player_index,
|
input_config_get_prefix(player_index,
|
||||||
input_config_bind_map[i].meta),
|
input_config_bind_map[i].meta),
|
||||||
|
@ -325,11 +328,12 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf,
|
||||||
|
|
||||||
if (quark)
|
if (quark)
|
||||||
{
|
{
|
||||||
|
char buf[16] = {0};
|
||||||
|
char key[64] = {0};
|
||||||
|
|
||||||
fprintf(stderr, "\tJoyhat moved: Hat %d, direction %s\n", j, quark);
|
fprintf(stderr, "\tJoyhat moved: Hat %d, direction %s\n", j, quark);
|
||||||
char buf[16];
|
|
||||||
snprintf(buf, sizeof(buf), "h%d%s", j, quark);
|
snprintf(buf, sizeof(buf), "h%d%s", j, quark);
|
||||||
|
|
||||||
char key[64];
|
|
||||||
snprintf(key, sizeof(key), "%s_%s_btn",
|
snprintf(key, sizeof(key), "%s_%s_btn",
|
||||||
input_config_get_prefix(player_index,
|
input_config_get_prefix(player_index,
|
||||||
input_config_bind_map[i].meta),
|
input_config_bind_map[i].meta),
|
||||||
|
|
Loading…
Reference in New Issue