Skip to content

Commit fa0f84a

Browse files
committed
fix: Make rtc_options non-static.
1 parent 4aa7a87 commit fa0f84a

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/include/Config/PlatformConfig.hpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,14 @@ namespace pew::eos::config
143143
*/
144144
std::string overrideLocaleCode;
145145

146-
virtual const char* get_cache_directory() const = 0;
147-
148-
virtual void set_platform_specific_rtc_options() const = 0;
146+
const char* get_cache_directory() const
147+
{
148+
return cache_directory.c_str();
149+
}
149150

150151
EOS_Platform_RTCOptions* get_platform_rtc_options() const
151152
{
152-
if (s_rtc_options == nullptr)
153-
{
154-
s_rtc_options = new EOS_Platform_RTCOptions();
155-
s_rtc_options->ApiVersion = EOS_PLATFORM_RTCOPTIONS_API_LATEST;
156-
set_platform_specific_rtc_options();
157-
}
158-
159-
return s_rtc_options;
153+
return rtc_options;
160154
}
161155

162156
protected:
@@ -167,10 +161,12 @@ namespace pew::eos::config
167161

168162
virtual void set_cache_directory() = 0;
169163

164+
virtual void set_platform_specific_rtc_options() const = 0;
165+
170166
/**
171-
* \brief Used to statically store the rtc options once it has been determined.
167+
* \brief Used to store the rtc options once it has been determined.
172168
*/
173-
static inline EOS_Platform_RTCOptions* s_rtc_options;
169+
EOS_Platform_RTCOptions* rtc_options;
174170

175171
explicit PlatformConfig(const char* file_name) : Config(file_name),
176172
is_server(false),
@@ -298,12 +294,22 @@ namespace pew::eos::config
298294
delete s_platform_specific_rtc_options;
299295

300296
// Free the dynamically allocated memory for the rtc options
301-
if (s_rtc_options != nullptr)
302-
delete s_rtc_options;
297+
if (rtc_options != nullptr)
298+
delete rtc_options;
303299
};
304300

305301
private:
306302

303+
void set_platform_rtc_options()
304+
{
305+
if (rtc_options == nullptr)
306+
{
307+
rtc_options = new EOS_Platform_RTCOptions();
308+
rtc_options->ApiVersion = EOS_PLATFORM_RTCOPTIONS_API_LATEST;
309+
set_platform_specific_rtc_options();
310+
}
311+
}
312+
307313
void initialize()
308314
{
309315
set_cache_directory();

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/include/Config/WindowsConfig.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,15 @@ namespace pew::eos::config
4747
}
4848
}
4949

50-
const char* get_cache_directory() const override
51-
{
52-
return cache_directory.c_str();
53-
}
54-
5550
void set_platform_specific_rtc_options() const override
5651
{
57-
if (s_rtc_options == nullptr)
52+
if (rtc_options == nullptr)
5853
{
59-
get_platform_rtc_options();
54+
logging::log_error("Attempting to set platform specific rtc options, but rtc options are null.");
6055
return;
6156
}
6257

63-
if (s_rtc_options->PlatformSpecificOptions == nullptr)
58+
if (rtc_options->PlatformSpecificOptions == nullptr)
6459
{
6560
s_platform_specific_rtc_options = new EOS_Windows_RTCOptions();
6661

@@ -82,7 +77,7 @@ namespace pew::eos::config
8277

8378
windows_rtc_options->XAudio29DllPath = s_xaudio2_dll_path.get();
8479

85-
s_rtc_options->PlatformSpecificOptions = s_platform_specific_rtc_options;
80+
rtc_options->PlatformSpecificOptions = s_platform_specific_rtc_options;
8681
}
8782
}
8883

0 commit comments

Comments
 (0)