mirror of
https://github.com/esuo1198/TaikoArcadeLoader.git
synced 2026-09-27 09:23:09 +03:00
Change to use unique_ptr
This commit is contained in:
+6
-7
@@ -321,8 +321,9 @@ Init () {
|
||||
INSTALL_HOOK (bngrw_attach);
|
||||
INSTALL_HOOK (bngrw_reqWaitTouch);
|
||||
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
toml_table_t *config = openConfig (configPath);
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> config_ptr (openConfig (configPath), toml_free);
|
||||
toml_table_t *config = config_ptr.get ();
|
||||
if (config) {
|
||||
auto drum = openConfigSection (config, "drum");
|
||||
if (drum) drumWaitPeriod = readConfigInt (drum, "wait_period", drumWaitPeriod);
|
||||
@@ -331,11 +332,11 @@ Init () {
|
||||
useTaikoController = readConfigBool (taikoController, "analog", useTaikoController);
|
||||
if (useTaikoController) printf ("Using analog input mode. All the keyboard drum inputs have been disabled.\n");
|
||||
}
|
||||
toml_free (config);
|
||||
}
|
||||
|
||||
auto keyconfigPath = std::filesystem::current_path () / "keyconfig.toml";
|
||||
toml_table_t *keyconfig = openConfig (keyconfigPath);
|
||||
auto keyconfigPath = std::filesystem::current_path () / "keyconfig.toml";
|
||||
std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> keyconfig_ptr (openConfig (keyconfigPath), toml_free);
|
||||
toml_table_t *keyconfig = keyconfig_ptr.get ();
|
||||
if (keyconfig) {
|
||||
SetConfigValue (keyconfig, "EXIT", &EXIT);
|
||||
|
||||
@@ -359,8 +360,6 @@ Init () {
|
||||
SetConfigValue (keyconfig, "P2_LEFT_RED", &P2_LEFT_RED);
|
||||
SetConfigValue (keyconfig, "P2_RIGHT_RED", &P2_RIGHT_RED);
|
||||
SetConfigValue (keyconfig, "P2_RIGHT_BLUE", &P2_RIGHT_BLUE);
|
||||
|
||||
toml_free (keyconfig);
|
||||
}
|
||||
}
|
||||
} // namespace bnusio
|
||||
|
||||
+4
-4
@@ -100,9 +100,10 @@ DllMain (HMODULE module, DWORD reason, LPVOID reserved) {
|
||||
// This is bad, dont do this
|
||||
// I/O in DllMain can easily cause a deadlock
|
||||
|
||||
const char *version = "auto";
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
toml_table_t *config = openConfig (configPath);
|
||||
const char *version = "auto";
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> config_ptr (openConfig (configPath), toml_free);
|
||||
toml_table_t *config = config_ptr.get ();
|
||||
if (config) {
|
||||
auto amauth = openConfigSection (config, "amauth");
|
||||
if (amauth) {
|
||||
@@ -122,7 +123,6 @@ DllMain (HMODULE module, DWORD reason, LPVOID reserved) {
|
||||
}
|
||||
auto patches = openConfigSection (config, "patches");
|
||||
if (patches) version = readConfigString (patches, "version", version);
|
||||
toml_free (config);
|
||||
}
|
||||
|
||||
if (!strcmp (version, "auto")) {
|
||||
|
||||
@@ -124,8 +124,9 @@ Init () {
|
||||
INSTALL_HOOK (HaspGetInfo);
|
||||
INSTALL_HOOK (HaspRead);
|
||||
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
toml_table_t *config = openConfig (configPath);
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> config_ptr (openConfig (configPath), toml_free);
|
||||
toml_table_t *config = config_ptr.get ();
|
||||
if (config) {
|
||||
auto patches = openConfigSection (config, "patches");
|
||||
if (patches) {
|
||||
@@ -145,7 +146,6 @@ Init () {
|
||||
modeCollabo026 = readConfigBool (cn_jun_2023, "mode_collabo026", modeCollabo026);
|
||||
}
|
||||
}
|
||||
toml_free (config);
|
||||
}
|
||||
|
||||
// Apply common config patch
|
||||
|
||||
@@ -48,8 +48,9 @@ Init () {
|
||||
bool sharedAudio = true;
|
||||
bool unlockSongs = true;
|
||||
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
toml_table_t *config = openConfig (configPath);
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> config_ptr (openConfig (configPath), toml_free);
|
||||
toml_table_t *config = config_ptr.get ();
|
||||
if (config) {
|
||||
auto patches = openConfigSection (config, "patches");
|
||||
if (patches) {
|
||||
@@ -62,7 +63,6 @@ Init () {
|
||||
sharedAudio = readConfigBool (patches, "shared_audio", sharedAudio);
|
||||
unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs);
|
||||
}
|
||||
toml_free (config);
|
||||
}
|
||||
|
||||
// Apply common config patch
|
||||
|
||||
@@ -52,8 +52,9 @@ Init () {
|
||||
bool sharedAudio = true;
|
||||
bool unlockSongs = true;
|
||||
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
toml_table_t *config = openConfig (configPath);
|
||||
auto configPath = std::filesystem::current_path () / "config.toml";
|
||||
std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> config_ptr (openConfig (configPath), toml_free);
|
||||
toml_table_t *config = config_ptr.get ();
|
||||
if (config) {
|
||||
auto patches = openConfigSection (config, "patches");
|
||||
if (patches) {
|
||||
@@ -66,7 +67,6 @@ Init () {
|
||||
sharedAudio = readConfigBool (patches, "shared_audio", sharedAudio);
|
||||
unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs);
|
||||
}
|
||||
toml_free (config);
|
||||
}
|
||||
|
||||
// Apply common config patch
|
||||
|
||||
Reference in New Issue
Block a user