mirror of https://github.com/OpenRCT2/OpenRCT2.git
Do not return shared_ptr for LocalisationService
GetLocalisationService is currently used a lot, so remove overhead of shared_ptr copy.
This commit is contained in:
parent
ad6ebd646c
commit
d1cbf998a0
|
@ -171,9 +171,9 @@ namespace OpenRCT2
|
||||||
return _env;
|
return _env;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<LocalisationService> GetLocalisationService() override
|
Localisation::LocalisationService& GetLocalisationService() override
|
||||||
{
|
{
|
||||||
return _localisationService;
|
return *_localisationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
IObjectManager * GetObjectManager() override
|
IObjectManager * GetObjectManager() override
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace OpenRCT2
|
||||||
virtual std::shared_ptr<Audio::IAudioContext> GetAudioContext() abstract;
|
virtual std::shared_ptr<Audio::IAudioContext> GetAudioContext() abstract;
|
||||||
virtual std::shared_ptr<Ui::IUiContext> GetUiContext() abstract;
|
virtual std::shared_ptr<Ui::IUiContext> GetUiContext() abstract;
|
||||||
virtual std::shared_ptr<IPlatformEnvironment> GetPlatformEnvironment() abstract;
|
virtual std::shared_ptr<IPlatformEnvironment> GetPlatformEnvironment() abstract;
|
||||||
virtual std::shared_ptr<Localisation::LocalisationService> GetLocalisationService() abstract;
|
virtual Localisation::LocalisationService& GetLocalisationService() abstract;
|
||||||
virtual IObjectManager * GetObjectManager() abstract;
|
virtual IObjectManager * GetObjectManager() abstract;
|
||||||
virtual IObjectRepository * GetObjectRepository() abstract;
|
virtual IObjectRepository * GetObjectRepository() abstract;
|
||||||
virtual ITrackDesignRepository * GetTrackDesignRepository() abstract;
|
virtual ITrackDesignRepository * GetTrackDesignRepository() abstract;
|
||||||
|
|
|
@ -95,17 +95,17 @@ uint8 language_get_id_from_locale(const char * locale)
|
||||||
const char * language_get_string(rct_string_id id)
|
const char * language_get_string(rct_string_id id)
|
||||||
{
|
{
|
||||||
const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
||||||
return localisationService->GetString(id);
|
return localisationService.GetString(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool language_open(sint32 id)
|
bool language_open(sint32 id)
|
||||||
{
|
{
|
||||||
auto context = OpenRCT2::GetContext();
|
auto context = OpenRCT2::GetContext();
|
||||||
const auto& localisationService = context->GetLocalisationService();
|
auto& localisationService = context->GetLocalisationService();
|
||||||
auto objectManager = context->GetObjectManager();
|
auto objectManager = context->GetObjectManager();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
localisationService->OpenLanguage(id, *objectManager);
|
localisationService.OpenLanguage(id, *objectManager);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (const std::exception&)
|
catch (const std::exception&)
|
||||||
|
@ -117,7 +117,7 @@ bool language_open(sint32 id)
|
||||||
bool language_get_localised_scenario_strings(const utf8 *scenarioFilename, rct_string_id *outStringIds)
|
bool language_get_localised_scenario_strings(const utf8 *scenarioFilename, rct_string_id *outStringIds)
|
||||||
{
|
{
|
||||||
const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
||||||
auto result = localisationService->GetLocalisedScenarioStrings(scenarioFilename);
|
auto result = localisationService.GetLocalisedScenarioStrings(scenarioFilename);
|
||||||
outStringIds[0] = std::get<0>(result);
|
outStringIds[0] = std::get<0>(result);
|
||||||
outStringIds[1] = std::get<1>(result);
|
outStringIds[1] = std::get<1>(result);
|
||||||
outStringIds[2] = std::get<2>(result);
|
outStringIds[2] = std::get<2>(result);
|
||||||
|
@ -129,18 +129,18 @@ bool language_get_localised_scenario_strings(const utf8 *scenarioFilename, rct_s
|
||||||
|
|
||||||
void language_free_object_string(rct_string_id stringId)
|
void language_free_object_string(rct_string_id stringId)
|
||||||
{
|
{
|
||||||
const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
||||||
localisationService->FreeObjectString(stringId);
|
localisationService.FreeObjectString(stringId);
|
||||||
}
|
}
|
||||||
|
|
||||||
rct_string_id language_get_object_override_string_id(const char * identifier, uint8 index)
|
rct_string_id language_get_object_override_string_id(const char * identifier, uint8 index)
|
||||||
{
|
{
|
||||||
const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
||||||
return localisationService->GetObjectOverrideStringId(identifier, index);
|
return localisationService.GetObjectOverrideStringId(identifier, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
rct_string_id language_allocate_object_string(const std::string &target)
|
rct_string_id language_allocate_object_string(const std::string &target)
|
||||||
{
|
{
|
||||||
const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService();
|
||||||
return localisationService->AllocateObjectString(target);
|
return localisationService.AllocateObjectString(target);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,11 +156,11 @@ void LocalisationService::FreeObjectString(rct_string_id stringId)
|
||||||
sint32 LocalisationService_GetCurrentLanguage()
|
sint32 LocalisationService_GetCurrentLanguage()
|
||||||
{
|
{
|
||||||
const auto& localisationService = GetContext()->GetLocalisationService();
|
const auto& localisationService = GetContext()->GetLocalisationService();
|
||||||
return localisationService->GetCurrentLanguage();
|
return localisationService.GetCurrentLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalisationService_UseTrueTypeFont()
|
bool LocalisationService_UseTrueTypeFont()
|
||||||
{
|
{
|
||||||
const auto& localisationService = GetContext()->GetLocalisationService();
|
const auto& localisationService = GetContext()->GetLocalisationService();
|
||||||
return localisationService->UseTrueTypeFont();
|
return localisationService.UseTrueTypeFont();
|
||||||
}
|
}
|
||||||
|
|
|
@ -667,9 +667,9 @@ const rct_object_entry * object_list_find(rct_object_entry * entry)
|
||||||
void object_list_load()
|
void object_list_load()
|
||||||
{
|
{
|
||||||
auto context = GetContext();
|
auto context = GetContext();
|
||||||
const auto localisationService = context->GetLocalisationService();
|
const auto& localisationService = context->GetLocalisationService();
|
||||||
auto objectRepository = context->GetObjectRepository();
|
auto objectRepository = context->GetObjectRepository();
|
||||||
objectRepository->LoadOrConstruct(localisationService->GetCurrentLanguage());
|
objectRepository->LoadOrConstruct(localisationService.GetCurrentLanguage());
|
||||||
|
|
||||||
IObjectManager * objectManager = context->GetObjectManager();
|
IObjectManager * objectManager = context->GetObjectManager();
|
||||||
objectManager->UnloadAll();
|
objectManager->UnloadAll();
|
||||||
|
|
Loading…
Reference in New Issue