1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Always pass shared_ptr by reference

This commit is contained in:
Ted John
2018-04-27 18:47:57 +01:00
parent d1cbf998a0
commit 302fe00805
24 changed files with 47 additions and 47 deletions

View File

@@ -94,7 +94,7 @@ private:
public:
InGameConsole& GetInGameConsole() { return _inGameConsole; }
explicit UiContext(std::shared_ptr<IPlatformEnvironment> env)
explicit UiContext(const std::shared_ptr<IPlatformEnvironment>& env)
: _platformUiContext(CreatePlatformUiContext()),
_windowManager(CreateWindowManager()),
_keyboardShortcuts(env)
@@ -803,7 +803,7 @@ private:
}
};
std::unique_ptr<IUiContext> OpenRCT2::Ui::CreateUiContext(std::shared_ptr<IPlatformEnvironment> env)
std::unique_ptr<IUiContext> OpenRCT2::Ui::CreateUiContext(const std::shared_ptr<IPlatformEnvironment>& env)
{
return std::make_unique<UiContext>(env);
}

View File

@@ -44,7 +44,7 @@ namespace OpenRCT2
virtual std::string ShowDirectoryDialog(SDL_Window * window, const std::string &title) abstract;
};
std::unique_ptr<IUiContext> CreateUiContext(std::shared_ptr<IPlatformEnvironment> env);
std::unique_ptr<IUiContext> CreateUiContext(const std::shared_ptr<IPlatformEnvironment>& env);
IPlatformUiContext * CreatePlatformUiContext();
InGameConsole& GetInGameConsole();

View File

@@ -28,16 +28,16 @@ namespace OpenRCT2
interface IUiContext;
std::unique_ptr<IDrawingEngine> CreateSoftwareDrawingEngine(std::shared_ptr<IUiContext> uiContext);
std::unique_ptr<IDrawingEngine> CreateHardwareDisplayDrawingEngine(std::shared_ptr<IUiContext> uiContext);
std::unique_ptr<IDrawingEngine> CreateSoftwareDrawingEngine(const std::shared_ptr<IUiContext>& uiContext);
std::unique_ptr<IDrawingEngine> CreateHardwareDisplayDrawingEngine(const std::shared_ptr<IUiContext>& uiContext);
#ifndef DISABLE_OPENGL
std::unique_ptr<IDrawingEngine> CreateOpenGLDrawingEngine(std::shared_ptr<IUiContext> uiContext);
std::unique_ptr<IDrawingEngine> CreateOpenGLDrawingEngine(const std::shared_ptr<IUiContext>& uiContext);
#endif
class DrawingEngineFactory final : public IDrawingEngineFactory
{
public:
std::unique_ptr<IDrawingEngine> Create(DRAWING_ENGINE_TYPE type, std::shared_ptr<IUiContext> uiContext) override
std::unique_ptr<IDrawingEngine> Create(DRAWING_ENGINE_TYPE type, const std::shared_ptr<IUiContext>& uiContext) override
{
switch ((sint32)type) {
case DRAWING_ENGINE_SOFTWARE:

View File

@@ -60,7 +60,7 @@ private:
bool smoothNN = false;
public:
explicit HardwareDisplayDrawingEngine(std::shared_ptr<IUiContext> uiContext)
explicit HardwareDisplayDrawingEngine(const std::shared_ptr<IUiContext>& uiContext)
: X8DrawingEngine(uiContext),
_uiContext(uiContext)
{
@@ -415,7 +415,7 @@ private:
}
};
std::unique_ptr<IDrawingEngine> OpenRCT2::Ui::CreateHardwareDisplayDrawingEngine(std::shared_ptr<IUiContext> uiContext)
std::unique_ptr<IDrawingEngine> OpenRCT2::Ui::CreateHardwareDisplayDrawingEngine(const std::shared_ptr<IUiContext>& uiContext)
{
return std::make_unique<HardwareDisplayDrawingEngine>(uiContext);
}

View File

@@ -39,7 +39,7 @@ private:
SDL_Palette * _palette = nullptr;
public:
explicit SoftwareDrawingEngine(std::shared_ptr<IUiContext> uiContext)
explicit SoftwareDrawingEngine(const std::shared_ptr<IUiContext>& uiContext)
: X8DrawingEngine(uiContext),
_uiContext(uiContext)
{
@@ -163,7 +163,7 @@ private:
}
};
std::unique_ptr<IDrawingEngine> OpenRCT2::Ui::CreateSoftwareDrawingEngine(std::shared_ptr<IUiContext> uiContext)
std::unique_ptr<IDrawingEngine> OpenRCT2::Ui::CreateSoftwareDrawingEngine(const std::shared_ptr<IUiContext>& uiContext)
{
return std::make_unique<SoftwareDrawingEngine>(uiContext);
}

View File

@@ -144,7 +144,7 @@ public:
SDL_Color Palette[256];
vec4 GLPalette[256];
explicit OpenGLDrawingEngine(std::shared_ptr<IUiContext> uiContext)
explicit OpenGLDrawingEngine(const std::shared_ptr<IUiContext>& uiContext)
: _uiContext(uiContext)
{
_window = (SDL_Window *)_uiContext->GetWindow();
@@ -419,7 +419,7 @@ private:
}
};
std::unique_ptr<IDrawingEngine> OpenRCT2::Ui::CreateOpenGLDrawingEngine(std::shared_ptr<IUiContext> uiContext)
std::unique_ptr<IDrawingEngine> OpenRCT2::Ui::CreateOpenGLDrawingEngine(const std::shared_ptr<IUiContext>& uiContext)
{
return std::make_unique<OpenGLDrawingEngine>(uiContext);
}

View File

@@ -32,7 +32,7 @@ using namespace OpenRCT2::Input;
// Remove when the C calls are removed
static KeyboardShortcuts * _instance;
KeyboardShortcuts::KeyboardShortcuts(std::shared_ptr<IPlatformEnvironment> env)
KeyboardShortcuts::KeyboardShortcuts(const std::shared_ptr<IPlatformEnvironment>& env)
: _env(env)
{
_instance = this;

View File

@@ -124,7 +124,7 @@ namespace OpenRCT2
uint16 _keys[SHORTCUT_COUNT];
public:
KeyboardShortcuts(std::shared_ptr<IPlatformEnvironment> env);
KeyboardShortcuts(const std::shared_ptr<IPlatformEnvironment>& env);
void Reset();
bool Load();

View File

@@ -119,9 +119,9 @@ namespace OpenRCT2
public:
Context(
std::shared_ptr<IPlatformEnvironment> env,
std::shared_ptr<IAudioContext> audioContext,
std::shared_ptr<IUiContext> uiContext)
const std::shared_ptr<IPlatformEnvironment>& env,
const std::shared_ptr<IAudioContext>& audioContext,
const std::shared_ptr<IUiContext>& uiContext)
: _env(env),
_audioContext(audioContext),
_uiContext(uiContext),
@@ -931,9 +931,9 @@ namespace OpenRCT2
}
PlainContext(
std::shared_ptr<IPlatformEnvironment> env,
std::shared_ptr<IAudioContext> audioContext,
std::shared_ptr<IUiContext> uiContext)
const std::shared_ptr<IPlatformEnvironment>& env,
const std::shared_ptr<IAudioContext>& audioContext,
const std::shared_ptr<IUiContext>& uiContext)
: Context(env, audioContext, uiContext),
_env(env),
_audioContext(audioContext),
@@ -950,9 +950,9 @@ namespace OpenRCT2
}
std::unique_ptr<IContext> CreateContext(
std::shared_ptr<IPlatformEnvironment> env,
std::shared_ptr<Audio::IAudioContext> audioContext,
std::shared_ptr<IUiContext> uiContext)
const std::shared_ptr<IPlatformEnvironment>& env,
const std::shared_ptr<Audio::IAudioContext>& audioContext,
const std::shared_ptr<IUiContext>& uiContext)
{
return std::make_unique<Context>(env, audioContext, uiContext);
}

View File

@@ -120,9 +120,9 @@ namespace OpenRCT2
std::unique_ptr<IContext> CreateContext();
std::unique_ptr<IContext> CreateContext(
std::shared_ptr<IPlatformEnvironment> env,
std::shared_ptr<Audio::IAudioContext> audioContext,
std::shared_ptr<Ui::IUiContext> uiContext);
const std::shared_ptr<IPlatformEnvironment>& env,
const std::shared_ptr<Audio::IAudioContext>& audioContext,
const std::shared_ptr<Ui::IUiContext>& uiContext);
IContext * GetContext();
} // namespace OpenRCT2

View File

@@ -80,7 +80,7 @@ namespace OpenRCT2::Drawing
interface IDrawingEngineFactory
{
virtual ~IDrawingEngineFactory() { }
virtual std::unique_ptr<IDrawingEngine> Create(DRAWING_ENGINE_TYPE type, std::shared_ptr<OpenRCT2::Ui::IUiContext> uiContext) abstract;
virtual std::unique_ptr<IDrawingEngine> Create(DRAWING_ENGINE_TYPE type, const std::shared_ptr<OpenRCT2::Ui::IUiContext>& uiContext) abstract;
};
interface IRainDrawer

View File

@@ -133,7 +133,7 @@ void X8RainDrawer::Restore()
#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
#endif
X8DrawingEngine::X8DrawingEngine(std::shared_ptr<Ui::IUiContext> uiContext)
X8DrawingEngine::X8DrawingEngine(const std::shared_ptr<Ui::IUiContext>& uiContext)
{
_drawingContext = new X8DrawingContext(this);
#ifdef __ENABLE_LIGHTFX__

View File

@@ -91,7 +91,7 @@ namespace OpenRCT2
X8DrawingContext * _drawingContext;
public:
explicit X8DrawingEngine(std::shared_ptr<Ui::IUiContext> uiContext);
explicit X8DrawingEngine(const std::shared_ptr<Ui::IUiContext>& uiContext);
~X8DrawingEngine() override;
void Initialise() override;

View File

@@ -142,7 +142,7 @@ Network::~Network()
CloseConnection();
}
void Network::SetEnvironment(std::shared_ptr<IPlatformEnvironment> env)
void Network::SetEnvironment(const std::shared_ptr<IPlatformEnvironment>& env)
{
_env = env;
}
@@ -2545,7 +2545,7 @@ void Network::Client_Handle_GAMEINFO(NetworkConnection& connection, NetworkPacke
network_chat_show_server_greeting();
}
void network_set_env(std::shared_ptr<IPlatformEnvironment> env)
void network_set_env(const std::shared_ptr<IPlatformEnvironment>& env)
{
gNetwork.SetEnvironment(env);
}
@@ -3327,7 +3327,7 @@ sint32 network_get_pickup_peep_old_x(uint8 playerid) { return _pickup_peep_old_x
void network_send_chat(const char* text) {}
void network_send_password(const char* password) {}
void network_close() {}
void network_set_env(std::shared_ptr<OpenRCT2::IPlatformEnvironment>) {}
void network_set_env(const std::shared_ptr<OpenRCT2::IPlatformEnvironment>&) {}
void network_shutdown_client() {}
void network_set_password(const char* password) {}
uint8 network_get_current_player_id() { return 0; }

View File

@@ -89,7 +89,7 @@ class Network
public:
Network();
~Network();
void SetEnvironment(std::shared_ptr<OpenRCT2::IPlatformEnvironment> env);
void SetEnvironment(const std::shared_ptr<OpenRCT2::IPlatformEnvironment>& env);
bool Init();
void Close();
bool BeginClient(const char* host, uint16 port);
@@ -301,7 +301,7 @@ private:
#endif /* DISABLE_NETWORK */
void network_set_env(std::shared_ptr<OpenRCT2::IPlatformEnvironment> env);
void network_set_env(const std::shared_ptr<OpenRCT2::IPlatformEnvironment>& env);
void network_close();
void network_shutdown_client();
sint32 network_begin_client(const char *host, sint32 port);

View File

@@ -215,7 +215,7 @@ class ObjectRepository final : public IObjectRepository
ObjectEntryMap _itemMap;
public:
explicit ObjectRepository(std::shared_ptr<IPlatformEnvironment> env)
explicit ObjectRepository(const std::shared_ptr<IPlatformEnvironment>& env)
: _env(env),
_fileIndex(*this, *env)
{
@@ -639,7 +639,7 @@ private:
}
};
IObjectRepository * CreateObjectRepository(std::shared_ptr<IPlatformEnvironment> env)
IObjectRepository * CreateObjectRepository(const std::shared_ptr<IPlatformEnvironment>& env)
{
return new ObjectRepository(env);
}

View File

@@ -83,7 +83,7 @@ interface IObjectRepository
virtual void WritePackedObjects(IStream * stream, std::vector<const ObjectRepositoryItem *> &objects) abstract;
};
IObjectRepository * CreateObjectRepository(std::shared_ptr<OpenRCT2::IPlatformEnvironment> env);
IObjectRepository * CreateObjectRepository(const std::shared_ptr<OpenRCT2::IPlatformEnvironment>& env);
bool IsObjectCustom(const ObjectRepositoryItem * object);

View File

@@ -34,7 +34,7 @@ using namespace OpenRCT2::Drawing;
using namespace OpenRCT2::Paint;
using namespace OpenRCT2::Ui;
Painter::Painter(std::shared_ptr<IUiContext> uiContext)
Painter::Painter(const std::shared_ptr<IUiContext>& uiContext)
: _uiContext(uiContext)
{
}

View File

@@ -45,7 +45,7 @@ namespace OpenRCT2
sint32 _frames = 0;
public:
explicit Painter(std::shared_ptr<Ui::IUiContext> uiContext);
explicit Painter(const std::shared_ptr<Ui::IUiContext>& uiContext);
void Paint(Drawing::IDrawingEngine& de);
private:

View File

@@ -143,7 +143,7 @@ private:
std::vector<TrackRepositoryItem> _items;
public:
explicit TrackDesignRepository(std::shared_ptr<IPlatformEnvironment> env)
explicit TrackDesignRepository(const std::shared_ptr<IPlatformEnvironment>& env)
: _env(env),
_fileIndex(*env)
{
@@ -398,7 +398,7 @@ private:
}
};
ITrackDesignRepository * CreateTrackDesignRepository(std::shared_ptr<IPlatformEnvironment> env)
ITrackDesignRepository * CreateTrackDesignRepository(const std::shared_ptr<IPlatformEnvironment>& env)
{
return new TrackDesignRepository(env);
}

View File

@@ -52,7 +52,7 @@ interface ITrackDesignRepository
virtual std::string Install(const std::string &path) abstract;
};
ITrackDesignRepository * CreateTrackDesignRepository(std::shared_ptr<OpenRCT2::IPlatformEnvironment> env);
ITrackDesignRepository * CreateTrackDesignRepository(const std::shared_ptr<OpenRCT2::IPlatformEnvironment>& env);
std::string GetNameFromTrackPath(const std::string &path);
void track_repository_scan();

View File

@@ -329,7 +329,7 @@ private:
std::vector<scenario_highscore_entry*> _highscores;
public:
explicit ScenarioRepository(std::shared_ptr<IPlatformEnvironment> env)
explicit ScenarioRepository(const std::shared_ptr<IPlatformEnvironment>& env)
: _env(env),
_fileIndex(*env)
{
@@ -730,7 +730,7 @@ private:
static ScenarioRepository * _scenarioRepository;
IScenarioRepository * CreateScenarioRepository(std::shared_ptr<IPlatformEnvironment> env)
IScenarioRepository * CreateScenarioRepository(const std::shared_ptr<IPlatformEnvironment>& env)
{
_scenarioRepository = new ScenarioRepository(env);
return _scenarioRepository;

View File

@@ -78,7 +78,7 @@ interface IScenarioRepository
virtual bool TryRecordHighscore(sint32 language, const utf8 * scenarioFileName, money32 companyValue, const utf8 * name) abstract;
};
IScenarioRepository * CreateScenarioRepository(std::shared_ptr<OpenRCT2::IPlatformEnvironment> env);
IScenarioRepository * CreateScenarioRepository(const std::shared_ptr<OpenRCT2::IPlatformEnvironment>& env);
IScenarioRepository * GetScenarioRepository();
void scenario_repository_scan();

View File

@@ -68,7 +68,7 @@ namespace OpenRCT2::Ui
class X8DrawingEngineFactory final : public IDrawingEngineFactory
{
std::unique_ptr<IDrawingEngine> Create(DRAWING_ENGINE_TYPE type, std::shared_ptr<IUiContext> uiContext) override
std::unique_ptr<IDrawingEngine> Create(DRAWING_ENGINE_TYPE type, const std::shared_ptr<IUiContext>& uiContext) override
{
return std::make_unique<X8DrawingEngine>(uiContext);
}