Get rid of global->patch

This commit is contained in:
twinaphex 2016-09-29 05:46:31 +02:00
parent 538aec6386
commit 89505fa011
6 changed files with 37 additions and 35 deletions

View File

@ -1172,11 +1172,11 @@ static void config_set_defaults(void)
*settings->directory.audio_filter = '\0'; *settings->directory.audio_filter = '\0';
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_UPS_PREF)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_UPS_PREF))
global->patch.ups_pref = false; rarch_ctl(RARCH_CTL_UNSET_UPS_PREF, NULL);
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_BPS_PREF)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_BPS_PREF))
global->patch.bps_pref = false; rarch_ctl(RARCH_CTL_UNSET_BPS_PREF, NULL);
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF))
global->patch.ips_pref = false; rarch_ctl(RARCH_CTL_UNSET_IPS_PREF, NULL);
*global->record.output_dir = '\0'; *global->record.output_dir = '\0';
*global->record.config_dir = '\0'; *global->record.config_dir = '\0';
@ -1772,17 +1772,26 @@ static bool config_load_file(const char *path, bool set_defaults,
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_UPS_PREF)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_UPS_PREF))
{ {
CONFIG_GET_BOOL_BASE(conf, global, patch.ups_pref, "ups_pref"); if (config_get_bool(conf, "ups_pref", &tmp_bool))
rarch_ctl(RARCH_CTL_SET_UPS_PREF, NULL);
else
rarch_ctl(RARCH_CTL_UNSET_UPS_PREF, NULL);
} }
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_BPS_PREF)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_BPS_PREF))
{ {
CONFIG_GET_BOOL_BASE(conf, global, patch.bps_pref, "bps_pref"); if (config_get_bool(conf, "bps_pref", &tmp_bool))
rarch_ctl(RARCH_CTL_SET_BPS_PREF, NULL);
else
rarch_ctl(RARCH_CTL_UNSET_BPS_PREF, NULL);
} }
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF))
{ {
CONFIG_GET_BOOL_BASE(conf, global, patch.ips_pref, "ips_pref"); if (config_get_bool(conf, "ips_pref", &tmp_bool))
rarch_ctl(RARCH_CTL_SET_IPS_PREF, NULL);
else
rarch_ctl(RARCH_CTL_UNSET_IPS_PREF, NULL);
} }
#ifdef HAVE_NETPLAY #ifdef HAVE_NETPLAY
@ -2971,11 +2980,11 @@ bool config_save_file(const char *path)
#endif #endif
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_UPS_PREF)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_UPS_PREF))
config_set_bool(conf, "ups_pref", global->patch.ups_pref); config_set_bool(conf, "ups_pref", rarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL));
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_BPS_PREF)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_BPS_PREF))
config_set_bool(conf, "bps_pref", global->patch.bps_pref); config_set_bool(conf, "bps_pref", rarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL));
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF))
config_set_bool(conf, "ips_pref", global->patch.ips_pref); config_set_bool(conf, "ips_pref", rarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL));
config_set_bool(conf, "log_verbosity", config_set_bool(conf, "log_verbosity",
verbosity_is_enabled()); verbosity_is_enabled());
config_set_bool(conf, "perfcnt_enable", config_set_bool(conf, "perfcnt_enable",

15
patch.c
View File

@ -32,6 +32,7 @@
#include "msg_hash.h" #include "msg_hash.h"
#include "patch.h" #include "patch.h"
#include "retroarch.h"
#include "runloop.h" #include "runloop.h"
#include "verbosity.h" #include "verbosity.h"
@ -555,7 +556,7 @@ error:
static bool try_bps_patch(uint8_t **buf, ssize_t *size) static bool try_bps_patch(uint8_t **buf, ssize_t *size)
{ {
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
bool allow_bps = !global->patch.ups_pref && !global->patch.ips_pref; bool allow_bps = !rarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL) && !rarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL);
if (!allow_bps || string_is_empty(global->name.bps)) if (!allow_bps || string_is_empty(global->name.bps))
return false; return false;
@ -567,7 +568,7 @@ static bool try_bps_patch(uint8_t **buf, ssize_t *size)
static bool try_ups_patch(uint8_t **buf, ssize_t *size) static bool try_ups_patch(uint8_t **buf, ssize_t *size)
{ {
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
bool allow_ups = !global->patch.bps_pref && !global->patch.ips_pref; bool allow_ups = !rarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL) && !rarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL);
if (!allow_ups || string_is_empty(global->name.ups)) if (!allow_ups || string_is_empty(global->name.ups))
return false; return false;
@ -579,7 +580,7 @@ static bool try_ups_patch(uint8_t **buf, ssize_t *size)
static bool try_ips_patch(uint8_t **buf, ssize_t *size) static bool try_ips_patch(uint8_t **buf, ssize_t *size)
{ {
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
bool allow_ips = !global->patch.ups_pref && !global->patch.bps_pref; bool allow_ips = !rarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL) && !rarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL);
if (!allow_ips || string_is_empty(global->name.ips)) if (!allow_ips || string_is_empty(global->name.ips))
return false; return false;
@ -598,11 +599,9 @@ static bool try_ips_patch(uint8_t **buf, ssize_t *size)
**/ **/
void patch_content(uint8_t **buf, ssize_t *size) void patch_content(uint8_t **buf, ssize_t *size)
{ {
global_t *global = global_get_ptr(); if ( (unsigned)rarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL)
+ (unsigned)rarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL)
if ( global->patch.ips_pref + (unsigned)rarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL) > 1)
+ global->patch.bps_pref
+ global->patch.ups_pref > 1)
{ {
RARCH_WARN("%s\n", RARCH_WARN("%s\n",
msg_hash_to_str(MSG_SEVERAL_PATCHES_ARE_EXPLICITLY_DEFINED)); msg_hash_to_str(MSG_SEVERAL_PATCHES_ARE_EXPLICITLY_DEFINED));

View File

@ -473,10 +473,9 @@ static void retroarch_parse_input(int argc, char *argv[])
retroarch_override_setting_free_state(); retroarch_override_setting_free_state();
rarch_ctl(RARCH_CTL_USERNAME_UNSET, NULL); rarch_ctl(RARCH_CTL_USERNAME_UNSET, NULL);
rarch_ctl(RARCH_CTL_UNSET_UPS_PREF, NULL);
global->patch.ups_pref = false; rarch_ctl(RARCH_CTL_UNSET_IPS_PREF, NULL);
global->patch.bps_pref = false; rarch_ctl(RARCH_CTL_UNSET_BPS_PREF, NULL);
global->patch.ips_pref = false;
*global->name.ups = '\0'; *global->name.ups = '\0';
*global->name.bps = '\0'; *global->name.bps = '\0';
*global->name.ips = '\0'; *global->name.ips = '\0';
@ -693,26 +692,26 @@ static void retroarch_parse_input(int argc, char *argv[])
case RA_OPT_BPS: case RA_OPT_BPS:
strlcpy(global->name.bps, optarg, strlcpy(global->name.bps, optarg,
sizeof(global->name.bps)); sizeof(global->name.bps));
global->patch.bps_pref = true; rarch_ctl(RARCH_CTL_SET_BPS_PREF, NULL);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_BPS_PREF); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_BPS_PREF);
break; break;
case 'U': case 'U':
strlcpy(global->name.ups, optarg, strlcpy(global->name.ups, optarg,
sizeof(global->name.ups)); sizeof(global->name.ups));
global->patch.ups_pref = true; rarch_ctl(RARCH_CTL_SET_UPS_PREF, NULL);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_UPS_PREF); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_UPS_PREF);
break; break;
case RA_OPT_IPS: case RA_OPT_IPS:
strlcpy(global->name.ips, optarg, strlcpy(global->name.ips, optarg,
sizeof(global->name.ips)); sizeof(global->name.ips));
global->patch.ips_pref = true; rarch_ctl(RARCH_CTL_SET_IPS_PREF, NULL);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_IPS_PREF); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_IPS_PREF);
break; break;
case RA_OPT_NO_PATCH: case RA_OPT_NO_PATCH:
global->patch.block_patch = true; rarch_ctl(RARCH_CTL_SET_PATCH_BLOCKED, NULL);
break; break;
case 'D': case 'D':

View File

@ -744,6 +744,10 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
rarch_ctl(RARCH_CTL_UNSET_SRAM_LOAD_DISABLED, NULL); rarch_ctl(RARCH_CTL_UNSET_SRAM_LOAD_DISABLED, NULL);
rarch_ctl(RARCH_CTL_UNSET_SRAM_SAVE_DISABLED, NULL); rarch_ctl(RARCH_CTL_UNSET_SRAM_SAVE_DISABLED, NULL);
rarch_ctl(RARCH_CTL_UNSET_SRAM_ENABLE, NULL); rarch_ctl(RARCH_CTL_UNSET_SRAM_ENABLE, NULL);
rarch_ctl(RARCH_CTL_UNSET_BPS_PREF, NULL);
rarch_ctl(RARCH_CTL_UNSET_IPS_PREF, NULL);
rarch_ctl(RARCH_CTL_UNSET_UPS_PREF, NULL);
rarch_ctl(RARCH_CTL_UNSET_PATCH_BLOCKED, NULL);
path_clear_content(); path_clear_content();
runloop_overrides_active = false; runloop_overrides_active = false;

View File

@ -154,14 +154,6 @@ typedef struct global
char remapfile[PATH_MAX_LENGTH]; char remapfile[PATH_MAX_LENGTH];
} name; } name;
struct
{
bool block_patch;
bool ups_pref;
bool bps_pref;
bool ips_pref;
} patch;
#ifdef HAVE_NETPLAY #ifdef HAVE_NETPLAY
/* Netplay. */ /* Netplay. */
struct struct

View File

@ -329,12 +329,11 @@ static bool load_content_into_memory(unsigned i, const char *path, void **buf,
if (i == 0) if (i == 0)
{ {
global_t *global = global_get_ptr();
/* First content file is significant, attempt to do patching, /* First content file is significant, attempt to do patching,
* CRC checking, etc. */ * CRC checking, etc. */
/* Attempt to apply a patch. */ /* Attempt to apply a patch. */
if (!global->patch.block_patch) if (!rarch_ctl(RARCH_CTL_IS_PATCH_BLOCKED, NULL))
patch_content(&ret_buf, length); patch_content(&ret_buf, length);
content_get_crc(&content_crc_ptr); content_get_crc(&content_crc_ptr);