1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-11-15 02:37:37 +01:00

clang-format pass

This commit is contained in:
Will Xyen 2020-01-10 17:24:47 -05:00
parent 3450686cf5
commit 66d1131664
14 changed files with 56 additions and 31 deletions

View File

@ -282,7 +282,7 @@ HRESULT my_GetAllocatedString(
// should probably check GUID, oh well
ret = real_GetAllocatedString(self, guidKey, ppwszValue, pcchLength);
char *pMBBuffer = (char *)malloc(0x100);
char *pMBBuffer = (char *) malloc(0x100);
wcstombs(pMBBuffer, *ppwszValue, 0x100);
log_info("Obtained: %s", pMBBuffer);

View File

@ -9,5 +9,6 @@ bool cconfig_hook_config_init(
const char *usage_header,
enum cconfig_cmd_usage_out cmd_usage_out)
{
return cconfig_main_config_init(config, "--config", NULL, "--help", "-h", usage_header, cmd_usage_out);
return cconfig_main_config_init(
config, "--config", NULL, "--help", "-h", usage_header, cmd_usage_out);
}

View File

@ -6,7 +6,7 @@
/**
* Init function for cconfig for hooks
*
*
* calls cconfig_main_config_init with some defaults for hook dlls
* see: cconfig_main_config_init for more details
*/

View File

@ -29,7 +29,8 @@ bool cconfig_main_config_init(
args_recover(&argc, &argv);
for (int i = 0; i < argc; i++) {
if (!strcmp(argv[i], help_parameter_short_name) || !strcmp(argv[i], help_parameter_name)) {
if (!strcmp(argv[i], help_parameter_short_name) ||
!strcmp(argv[i], help_parameter_name)) {
goto failure_usage;
}
}

View File

@ -6,7 +6,7 @@
/**
* Init function for cconfig after all cconfig_util_set's have been called
*
*
* will parse a config file first (if specified)
* then uses override config parameters from cmd
*/

View File

@ -52,13 +52,15 @@ void d3d9exhook_config_gfx_init(struct cconfig *config)
config,
D3D9EXHOOK_CONFIG_GFX_FORCED_RR_KEY,
D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCED_RR_VALUE,
"Forced refresh rate, -1 to not force any (try 59 or 60 if monitor check fails to lock on high refresh rate monitors)");
"Forced refresh rate, -1 to not force any (try 59 or 60 if monitor "
"check fails to lock on high refresh rate monitors)");
cconfig_util_set_int(
config,
D3D9EXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY,
D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE,
"D3D9ex device adapter (monitor), 0 (D3DADAPTER_DEFAULT) to use default, 1, 2 etc. to use specified adapter");
"D3D9ex device adapter (monitor), 0 (D3DADAPTER_DEFAULT) to use "
"default, 1, 2 etc. to use specified adapter");
}
void d3d9exhook_config_gfx_get(
@ -142,6 +144,7 @@ void d3d9exhook_config_gfx_get(
"to default '%d'",
D3D9EXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY,
D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE);
config_gfx->device_adapter = D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE;
config_gfx->device_adapter =
D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE;
}
}

View File

@ -5,7 +5,7 @@
/**
* Config struct for d3d9exhook
*
*
* Note: forced_refresh_rate sets the monitor's refresh rate
* (it does not limit FPS or anything)
*/

View File

@ -201,7 +201,10 @@ static HRESULT STDCALL my_CreateDeviceEx(
pp->FullScreen_RefreshRateInHz = 0;
} else {
if (d3d9ex_force_refresh_rate > 0) {
log_info("Forcing refresh rate %d -> %d", pp->FullScreen_RefreshRateInHz, d3d9ex_force_refresh_rate);
log_info(
"Forcing refresh rate %d -> %d",
pp->FullScreen_RefreshRateInHz,
d3d9ex_force_refresh_rate);
pp->FullScreen_RefreshRateInHz = d3d9ex_force_refresh_rate;
if (fdm) {
fdm->RefreshRate = pp->FullScreen_RefreshRateInHz;
@ -267,7 +270,7 @@ void d3d9ex_hook_init(void)
log_info("Inserted graphics hooks");
}
void d3d9ex_configure(struct d3d9exhook_config_gfx* gfx_config)
void d3d9ex_configure(struct d3d9exhook_config_gfx *gfx_config)
{
d3d9ex_windowed = gfx_config->windowed;
d3d9ex_window_framed = gfx_config->framed;

View File

@ -16,6 +16,6 @@ void d3d9ex_hook_init(void);
*
* @param gfx_config Config to apply.
*/
void d3d9ex_configure(struct d3d9exhook_config_gfx* gfx_config);
void d3d9ex_configure(struct d3d9exhook_config_gfx *gfx_config);
#endif

View File

@ -150,13 +150,15 @@ void iidxhook_config_gfx_init(struct cconfig *config)
config,
IIDXHOOK_CONFIG_GFX_FORCED_RR_KEY,
IIDXHOOK_CONFIG_GFX_DEFAULT_FORCED_RR_VALUE,
"Forced refresh rate, -1 to not force any (try 59 or 60 if monitor check fails to lock on high refresh rate monitors)");
"Forced refresh rate, -1 to not force any (try 59 or 60 if monitor "
"check fails to lock on high refresh rate monitors)");
cconfig_util_set_int(
config,
IIDXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY,
IIDXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE,
"D3D9 device adapter (monitor), 0 (D3DADAPTER_DEFAULT) to use default, 1, 2 etc. to use specified adapter");
"D3D9 device adapter (monitor), 0 (D3DADAPTER_DEFAULT) to use default, "
"1, 2 etc. to use specified adapter");
}
void iidxhook_config_gfx_get(
@ -372,6 +374,7 @@ void iidxhook_config_gfx_get(
"to default '%d'",
IIDXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY,
IIDXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE);
config_gfx->device_adapter = IIDXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE;
config_gfx->device_adapter =
IIDXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE;
}
}

View File

@ -269,14 +269,22 @@ static void iidxhook_util_d3d9_fix_create_device_apply_window_mode(
pp->FullScreen_RefreshRateInHz = 0;
} else {
if (iidxhook_util_d3d9_config.forced_refresh_rate > 0) {
log_info("Forcing refresh rate %d -> %d", pp->FullScreen_RefreshRateInHz, iidxhook_util_d3d9_config.forced_refresh_rate);
pp->FullScreen_RefreshRateInHz = iidxhook_util_d3d9_config.forced_refresh_rate;
log_info(
"Forcing refresh rate %d -> %d",
pp->FullScreen_RefreshRateInHz,
iidxhook_util_d3d9_config.forced_refresh_rate);
pp->FullScreen_RefreshRateInHz =
iidxhook_util_d3d9_config.forced_refresh_rate;
}
}
if (iidxhook_util_d3d9_config.device_adapter != D3DADAPTER_DEFAULT) {
log_info("Forcing adapter %d -> %d", irp->args.ctx_create_device.adapter, iidxhook_util_d3d9_config.device_adapter);
irp->args.ctx_create_device.adapter = iidxhook_util_d3d9_config.device_adapter;
log_info(
"Forcing adapter %d -> %d",
irp->args.ctx_create_device.adapter,
iidxhook_util_d3d9_config.device_adapter);
irp->args.ctx_create_device.adapter =
iidxhook_util_d3d9_config.device_adapter;
}
}

View File

@ -162,13 +162,15 @@ struct iidxhook_util_d3d9_config {
/**
* Forced refresh rate
* -1 to not force any (try 59 or 60 if monitor check fails to lock on high refresh rate monitors)
* -1 to not force any (try 59 or 60 if monitor check fails to lock on high
* refresh rate monitors)
*/
int32_t forced_refresh_rate;
/**
* override device adapter (monitor)
* 0 (D3DADAPTER_DEFAULT) to use default (whatever the game sends), 1, 2 etc. to use specified adapter
* 0 (D3DADAPTER_DEFAULT) to use default (whatever the game sends), 1, 2
* etc. to use specified adapter
*/
int32_t device_adapter;
};

View File

@ -247,7 +247,9 @@ int main(int argc, const char **argv)
if (path_exists(options.app_config_path)) {
app_config = boot_property_load(options.app_config_path);
} else {
log_warning("%s: app config file missing, using empty", options.app_config_path);
log_warning(
"%s: app config file missing, using empty",
options.app_config_path);
app_config = boot_property_load_cstring("<param>dummy</param>");
}

View File

@ -21,19 +21,20 @@ static int boot_property_fread(uint32_t context, void *bytes, size_t nbytes)
}
struct cstring_read_handle {
const char * buffer;
const char *buffer;
size_t buffer_len;
size_t offset;
};
static int boot_property_cstring_read(uint32_t context, void *bytes, size_t nbytes)
static int
boot_property_cstring_read(uint32_t context, void *bytes, size_t nbytes)
{
int result = 0;
struct cstring_read_handle* h = TlsGetValue(context);
struct cstring_read_handle *h = TlsGetValue(context);
if (h->offset < h->buffer_len){
if (h->offset < h->buffer_len) {
result = min(nbytes, h->buffer_len - h->offset);
memcpy(bytes, (const void *)(h->buffer + h->offset), result);
memcpy(bytes, (const void *) (h->buffer + h->offset), result);
h->offset += result;
}
return result;
@ -100,7 +101,8 @@ struct property *boot_property_load_cstring(const char *cstring)
s_keyhole = TlsAlloc();
TlsSetValue(s_keyhole, &read_handle);
nbytes = property_read_query_memsize(boot_property_cstring_read, s_keyhole, 0, 0);
nbytes = property_read_query_memsize(
boot_property_cstring_read, s_keyhole, 0, 0);
if (nbytes < 0) {
log_fatal("Error querying configuration string");
@ -108,10 +110,10 @@ struct property *boot_property_load_cstring(const char *cstring)
buffer = xmalloc(nbytes);
prop = property_create(
PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE | PROPERTY_FLAG_CREATE | PROPERTY_FLAG_APPEND,
PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE | PROPERTY_FLAG_CREATE |
PROPERTY_FLAG_APPEND,
buffer,
nbytes
);
nbytes);
read_handle.offset = 0;
if (!property_insert_read(prop, 0, boot_property_cstring_read, s_keyhole)) {