mirror of
https://github.com/pumpitupdev/pumptools.git
synced 2026-10-14 09:59:22 +03:00
Appl new code style on whole code base
Use a similar code style to bemanitools though reduce indentation to 2 spaces. Also some other tweaks to be more similar to google style.
This commit is contained in:
@@ -12,59 +12,65 @@
|
||||
|
||||
static bool nx2hook_profile_gen_is_creating_file;
|
||||
|
||||
// Do not use util_fs_path_exists here as this fopens and causes an endless recursion
|
||||
static bool nx2hook_profile_gen_check_if_exists(const char* path)
|
||||
// Do not use util_fs_path_exists here as this fopens and causes an endless
|
||||
// recursion
|
||||
static bool nx2hook_profile_gen_check_if_exists(const char *path)
|
||||
{
|
||||
return access(path, F_OK) != -1;
|
||||
return access(path, F_OK) != -1;
|
||||
}
|
||||
|
||||
static enum cnh_result nx2hook_profile_gen_filehook(struct cnh_filehook_irp *irp)
|
||||
static enum cnh_result
|
||||
nx2hook_profile_gen_filehook(struct cnh_filehook_irp *irp)
|
||||
{
|
||||
// nx2hook_profile_gen_is_creating_file: Avoid recursion of any file calls when creating the save/rank files
|
||||
if (irp->op != CNH_FILEHOOK_IRP_OP_OPEN || nx2hook_profile_gen_is_creating_file) {
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
}
|
||||
|
||||
if (util_str_ends_with(irp->open_filename, "nx2save.bin") &&
|
||||
!nx2hook_profile_gen_check_if_exists(irp->open_filename)) {
|
||||
nx2hook_profile_gen_is_creating_file = true;
|
||||
|
||||
struct asset_nx2_usb_save* save = asset_nx2_usb_save_new();
|
||||
asset_nx2_usb_save_finalize(save);
|
||||
|
||||
log_info("No %s file found, generate new", irp->open_filename);
|
||||
|
||||
if (!asset_nx2_usb_save_save_to_file(irp->open_filename, save, true)) {
|
||||
log_error("Saving generated nx2save.bin file to %s failed", irp->open_filename);
|
||||
}
|
||||
|
||||
free(save);
|
||||
|
||||
nx2hook_profile_gen_is_creating_file = false;
|
||||
}
|
||||
|
||||
if (util_str_ends_with(irp->open_filename, "nx2rank.bin") &&
|
||||
!nx2hook_profile_gen_check_if_exists(irp->open_filename)) {
|
||||
nx2hook_profile_gen_is_creating_file = true;
|
||||
|
||||
struct asset_nx2_usb_rank* rank = asset_nx2_usb_rank_new();
|
||||
asset_nx2_usb_rank_finalize(rank);
|
||||
|
||||
log_info("No %s file found, generate new", irp->open_filename);
|
||||
|
||||
if (!asset_nx2_usb_rank_save_to_file(irp->open_filename, rank, true)) {
|
||||
log_error("Saving generated nx2rank.bin file to %s failed", irp->open_filename);
|
||||
}
|
||||
|
||||
free(rank);
|
||||
|
||||
nx2hook_profile_gen_is_creating_file = false;
|
||||
}
|
||||
|
||||
// nx2hook_profile_gen_is_creating_file: Avoid recursion of any file calls
|
||||
// when creating the save/rank files
|
||||
if (irp->op != CNH_FILEHOOK_IRP_OP_OPEN ||
|
||||
nx2hook_profile_gen_is_creating_file) {
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
}
|
||||
|
||||
if (util_str_ends_with(irp->open_filename, "nx2save.bin") &&
|
||||
!nx2hook_profile_gen_check_if_exists(irp->open_filename)) {
|
||||
nx2hook_profile_gen_is_creating_file = true;
|
||||
|
||||
struct asset_nx2_usb_save *save = asset_nx2_usb_save_new();
|
||||
asset_nx2_usb_save_finalize(save);
|
||||
|
||||
log_info("No %s file found, generate new", irp->open_filename);
|
||||
|
||||
if (!asset_nx2_usb_save_save_to_file(irp->open_filename, save, true)) {
|
||||
log_error(
|
||||
"Saving generated nx2save.bin file to %s failed", irp->open_filename);
|
||||
}
|
||||
|
||||
free(save);
|
||||
|
||||
nx2hook_profile_gen_is_creating_file = false;
|
||||
}
|
||||
|
||||
if (util_str_ends_with(irp->open_filename, "nx2rank.bin") &&
|
||||
!nx2hook_profile_gen_check_if_exists(irp->open_filename)) {
|
||||
nx2hook_profile_gen_is_creating_file = true;
|
||||
|
||||
struct asset_nx2_usb_rank *rank = asset_nx2_usb_rank_new();
|
||||
asset_nx2_usb_rank_finalize(rank);
|
||||
|
||||
log_info("No %s file found, generate new", irp->open_filename);
|
||||
|
||||
if (!asset_nx2_usb_rank_save_to_file(irp->open_filename, rank, true)) {
|
||||
log_error(
|
||||
"Saving generated nx2rank.bin file to %s failed", irp->open_filename);
|
||||
}
|
||||
|
||||
free(rank);
|
||||
|
||||
nx2hook_profile_gen_is_creating_file = false;
|
||||
}
|
||||
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
}
|
||||
|
||||
void nx2hook_profile_gen_init(void)
|
||||
{
|
||||
cnh_filehook_push_handler(nx2hook_profile_gen_filehook);
|
||||
cnh_filehook_push_handler(nx2hook_profile_gen_filehook);
|
||||
}
|
||||
Reference in New Issue
Block a user