Skip to content

Commit dc49919

Browse files
committed
Fixed issue with plugin not loading with Non-English characters in file path
1 parent 875e88a commit dc49919

File tree

6 files changed

+40
-26
lines changed

6 files changed

+40
-26
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.47.1
2+
- Fixed issue with plugin not loading with Non-English characters in file path
3+
14
## 1.47
25
- Updated to support 1.47
36
- Added some extra (error) logging

dist/ts-fmod-plugin.dll

3 KB
Binary file not shown.

ts-fmod-plugin/dllmain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ SCSAPI_RESULT scs_telemetry_init(const scs_u32_t version, const scs_telemetry_in
251251
scs_log = version_params->common.log;
252252

253253
scs_log(0,
254-
"[ts-fmod-plugin V1.47] Searching for economy offset... If this is one of the last messages in the log after a crash, try disabling this plugin.");
254+
"[ts-fmod-plugin V1.47.1] Searching for economy offset... If this is one of the last messages in the log after a crash, try disabling this plugin.");
255255

256256
auto addr = pattern::scan("48 8B 05 ? ? ? ? 48 8B D9 8B 90 ? ? ? ? 48 8B 80 ? ? ? ? 48 8B 88 ? ? ? ? E8",
257257
game_base,

ts-fmod-plugin/fmod_manager.cpp

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ fmod_manager::~fmod_manager()
1313
CoUninitialize();
1414
}
1515

16-
bool fmod_manager::load_selected_bank(const std::string& plugin_files_dir)
16+
bool fmod_manager::load_selected_bank(const std::filesystem::path& plugin_files_dir)
1717
{
18-
const auto selected_bank_file_path = plugin_files_dir + "selected.bank.txt";
18+
auto selected_bank_file_path = plugin_files_dir;
19+
selected_bank_file_path.append("selected.bank.txt");
1920

20-
if (!fs::exists(selected_bank_file_path))
21+
if (!exists(selected_bank_file_path))
2122
{
2223
scs_log_(SCS_LOG_TYPE_error, "[ts-fmod-plugin] Could not find the 'selected.bank.txt' file");
2324
return false;
@@ -35,9 +36,13 @@ bool fmod_manager::load_selected_bank(const std::string& plugin_files_dir)
3536
int i = 0;
3637
while (selected_bank_file >> bank_name)
3738
{
38-
const auto res = system_->loadBankFile((plugin_files_dir + bank_name + ".bank").c_str(),
39-
FMOD_STUDIO_LOAD_BANK_NORMAL,
40-
&bank);
39+
auto bank_file_path = plugin_files_dir;
40+
bank_file_path.append(bank_name).concat(".bank");
41+
42+
const auto res = system_->loadBankFile(
43+
bank_file_path.generic_u8string().c_str(),
44+
FMOD_STUDIO_LOAD_BANK_NORMAL,
45+
&bank);
4146
if (res != FMOD_OK)
4247
{
4348
std::stringstream ss;
@@ -63,8 +68,7 @@ bool fmod_manager::init()
6368
scs_log_(SCS_LOG_TYPE_error, "[ts-fmod-plugin] CoInitializeEx Failed");
6469
return false;
6570
}
66-
67-
auto plugin_files_dir = fs::current_path().generic_u8string() + "/plugins/ts-fmod-plugin/";
71+
const auto plugin_files_dir = fs::current_path().append("plugins/ts-fmod-plugin");
6872
auto res = FMOD::Studio::System::create(&system_);
6973
if (res != FMOD_OK)
7074
{
@@ -114,9 +118,13 @@ bool fmod_manager::init()
114118

115119
FMOD::Studio::Bank* bank;
116120

117-
res = system_->loadBankFile((plugin_files_dir + "master.bank").c_str(),
121+
auto master_bank_path = plugin_files_dir;
122+
master_bank_path.append("master.bank");
123+
124+
res = system_->loadBankFile(master_bank_path.generic_u8string().c_str(),
118125
FMOD_STUDIO_LOAD_BANK_NORMAL,
119126
&bank);
127+
120128
if (res != FMOD_OK)
121129
{
122130
std::stringstream ss;
@@ -166,15 +174,18 @@ bool fmod_manager::init()
166174
return true;
167175
}
168176

169-
bool fmod_manager::init_channels(const std::string& plugin_files_dir)
177+
bool fmod_manager::init_channels(const std::filesystem::path& plugin_files_dir)
170178
{
171179
for (const std::string& bank_name : selected_bank_names_)
172180
{
173181
std::stringstream ss;
174182
ss << "[ts-fmod-plugin] Loading the events and busses for '" << bank_name << "'";
175183
scs_log_(SCS_LOG_TYPE_message, ss.str().c_str());
176-
auto guids_file_path = plugin_files_dir + bank_name + ".bank.guids";
177-
if (!fs::exists(guids_file_path))
184+
185+
auto guids_file_path = plugin_files_dir;
186+
guids_file_path.append(bank_name).concat(".bank.guids");
187+
188+
if (!exists(guids_file_path))
178189
{
179190
scs_log_(SCS_LOG_TYPE_error, "[ts-fmod-plugin] Could not find the '*.bank.guids' file");
180191
return false;
@@ -261,11 +272,11 @@ float fmod_manager::get_sound_level_from_json(json j, const char* key, float def
261272
return val / 2;
262273
}
263274

264-
bool fmod_manager::load_sound_levels(const std::string& plugin_files_dir)
275+
bool fmod_manager::load_sound_levels(std::filesystem::path plugin_files_dir)
265276
{
266-
const auto sound_levels_file_path = plugin_files_dir + "sound_levels.txt";
277+
const auto sound_levels_file_path = plugin_files_dir.append("sound_levels.txt");
267278

268-
if (!fs::exists(sound_levels_file_path))
279+
if (!exists(sound_levels_file_path))
269280
{
270281
scs_log_(SCS_LOG_TYPE_error, "[ts-fmod-plugin] Could not find the 'sound_levels.txt' file");
271282
return false;

ts-fmod-plugin/fmod_manager.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ using json = nlohmann::json;
66

77
#include "fmod_event.h"
88

9-
struct sound_levels_t {
9+
struct sound_levels_t
10+
{
1011
float master = 0.25f;
1112
float engine = 0.25f;
1213
float exhaust = 0.25f;
@@ -27,11 +28,11 @@ class fmod_manager
2728
std::unordered_map<std::string, FMOD::Studio::Bus*> fmod_busses_map_;
2829

2930

30-
bool load_selected_bank(const std::string& plugin_files_dir);
31-
bool init_channels(const std::string& plugin_files_dir);
31+
bool load_selected_bank(const std::filesystem::path& plugin_files_dir);
32+
bool init_channels(const std::filesystem::path& plugin_files_dir);
3233

33-
float get_sound_level_from_json(json j, const char* key, float defaultValue);
34-
bool load_sound_levels(const std::string& plugin_files_dir);
34+
float get_sound_level_from_json(json j, const char* key, float default_value);
35+
bool load_sound_levels(std::filesystem::path plugin_files_dir);
3536

3637
public:
3738
sound_levels_t sound_levels;
@@ -54,4 +55,3 @@ class fmod_manager
5455
FMOD_RESULT set_bus_volume(const char* bus_name, float value);
5556
FMOD_RESULT pause_bus(const char* bus_name, bool state);
5657
};
57-

ts-fmod-plugin/ts-fmod-plugin.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ END
5151
//
5252

5353
VS_VERSION_INFO VERSIONINFO
54-
FILEVERSION 1,47,0,0
55-
PRODUCTVERSION 1,47,0,0
54+
FILEVERSION 1,47,1,0
55+
PRODUCTVERSION 1,47,1,0
5656
FILEFLAGSMASK 0x3fL
5757
#ifdef _DEBUG
5858
FILEFLAGS 0x1L
@@ -69,12 +69,12 @@ BEGIN
6969
BEGIN
7070
VALUE "CompanyName", "Dario Wouters"
7171
VALUE "FileDescription", "Sound Plugin for ATS/ETS2"
72-
VALUE "FileVersion", "1.47.0.0"
72+
VALUE "FileVersion", "1.47.1.0"
7373
VALUE "InternalName", "ts-fmod-plugin.dll"
7474
VALUE "LegalCopyright", "Copyright (C) 2022"
7575
VALUE "OriginalFilename", "ts-fmod-plugin.dll"
7676
VALUE "ProductName", "Sound Plugin for ATS/ETS2"
77-
VALUE "ProductVersion", "1.47.0.0"
77+
VALUE "ProductVersion", "1.47.1.0"
7878
END
7979
END
8080
BLOCK "VarFileInfo"

0 commit comments

Comments
 (0)