mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Pass span of strings to drivers instead of StringList.
StringList is a `std::vector<std::string>`, and drivers do not need to modify the parameters. This also renames parameter to be the same for all implementations.pull/13139/head
parent
3a310f1802
commit
37934f0a3c
|
@ -41,7 +41,7 @@ static const std::string HWACCELERATION_TEST_FILE = "hwaccel.dat"; ///< Filename
|
||||||
* @param name The parameter name we're looking for.
|
* @param name The parameter name we're looking for.
|
||||||
* @return The parameter value.
|
* @return The parameter value.
|
||||||
*/
|
*/
|
||||||
const char *GetDriverParam(const StringList &parm, const char *name)
|
const char *GetDriverParam(std::span<const std::string> parm, const char *name)
|
||||||
{
|
{
|
||||||
if (parm.empty()) return nullptr;
|
if (parm.empty()) return nullptr;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ const char *GetDriverParam(const StringList &parm, const char *name)
|
||||||
* @param name The parameter name we're looking for.
|
* @param name The parameter name we're looking for.
|
||||||
* @return The parameter value.
|
* @return The parameter value.
|
||||||
*/
|
*/
|
||||||
bool GetDriverParamBool(const StringList &parm, const char *name)
|
bool GetDriverParamBool(std::span<const std::string> parm, const char *name)
|
||||||
{
|
{
|
||||||
return GetDriverParam(parm, name) != nullptr;
|
return GetDriverParam(parm, name) != nullptr;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ bool GetDriverParamBool(const StringList &parm, const char *name)
|
||||||
* @param def The default value if the parameter doesn't exist.
|
* @param def The default value if the parameter doesn't exist.
|
||||||
* @return The parameter value.
|
* @return The parameter value.
|
||||||
*/
|
*/
|
||||||
int GetDriverParamInt(const StringList &parm, const char *name, int def)
|
int GetDriverParamInt(std::span<const std::string> parm, const char *name, int def)
|
||||||
{
|
{
|
||||||
const char *p = GetDriverParam(parm, name);
|
const char *p = GetDriverParam(parm, name);
|
||||||
return p != nullptr ? atoi(p) : def;
|
return p != nullptr ? atoi(p) : def;
|
||||||
|
|
|
@ -11,11 +11,10 @@
|
||||||
#define DRIVER_H
|
#define DRIVER_H
|
||||||
|
|
||||||
#include "core/enum_type.hpp"
|
#include "core/enum_type.hpp"
|
||||||
#include "string_type.h"
|
|
||||||
|
|
||||||
const char *GetDriverParam(const StringList &parm, const char *name);
|
const char *GetDriverParam(std::span<const std::string> parm, const char *name);
|
||||||
bool GetDriverParamBool(const StringList &parm, const char *name);
|
bool GetDriverParamBool(std::span<const std::string> parm, const char *name);
|
||||||
int GetDriverParamInt(const StringList &parm, const char *name, int def);
|
int GetDriverParamInt(std::span<const std::string> parm, const char *name, int def);
|
||||||
|
|
||||||
/** A driver for communicating with the user. */
|
/** A driver for communicating with the user. */
|
||||||
class Driver {
|
class Driver {
|
||||||
|
@ -25,7 +24,7 @@ public:
|
||||||
* @param parm Parameters passed to the driver.
|
* @param parm Parameters passed to the driver.
|
||||||
* @return std::nullopt if everything went okay, otherwise an error message.
|
* @return std::nullopt if everything went okay, otherwise an error message.
|
||||||
*/
|
*/
|
||||||
virtual std::optional<std::string_view> Start(const StringList &parm) = 0;
|
virtual std::optional<std::string_view> Start(std::span<const std::string> parm) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop this driver.
|
* Stop this driver.
|
||||||
|
|
|
@ -26,7 +26,7 @@ static MIDI *_midi = nullptr;
|
||||||
*/
|
*/
|
||||||
extern int _allegro_instance_count;
|
extern int _allegro_instance_count;
|
||||||
|
|
||||||
std::optional<std::string_view> MusicDriver_Allegro::Start(const StringList &)
|
std::optional<std::string_view> MusicDriver_Allegro::Start(std::span<const std::string> )
|
||||||
{
|
{
|
||||||
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
|
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
|
||||||
Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error);
|
Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** Allegro's music player. */
|
/** Allegro's music player. */
|
||||||
class MusicDriver_Allegro : public MusicDriver {
|
class MusicDriver_Allegro : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
/** Factory for BeOS' midi player. */
|
/** Factory for BeOS' midi player. */
|
||||||
static FMusicDriver_BeMidi iFMusicDriver_BeMidi;
|
static FMusicDriver_BeMidi iFMusicDriver_BeMidi;
|
||||||
|
|
||||||
std::optional<std::string_view> MusicDriver_BeMidi::Start(const StringList &parm)
|
std::optional<std::string_view> MusicDriver_BeMidi::Start(std::span<const std::string>)
|
||||||
{
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
/** The midi player for BeOS. */
|
/** The midi player for BeOS. */
|
||||||
class MusicDriver_BeMidi : public MusicDriver {
|
class MusicDriver_BeMidi : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
|
||||||
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ static void DoSetVolume()
|
||||||
/**
|
/**
|
||||||
* Initialized the MIDI player, including QuickTime initialization.
|
* Initialized the MIDI player, including QuickTime initialization.
|
||||||
*/
|
*/
|
||||||
std::optional<std::string_view> MusicDriver_Cocoa::Start(const StringList &)
|
std::optional<std::string_view> MusicDriver_Cocoa::Start(std::span<const std::string>)
|
||||||
{
|
{
|
||||||
if (NewMusicPlayer(&_player) != noErr) return "failed to create music player";
|
if (NewMusicPlayer(&_player) != noErr) return "failed to create music player";
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
class MusicDriver_Cocoa : public MusicDriver {
|
class MusicDriver_Cocoa : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -1063,7 +1063,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::optional<std::string_view> MusicDriver_DMusic::Start(const StringList &parm)
|
std::optional<std::string_view> MusicDriver_DMusic::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
/* Initialize COM */
|
/* Initialize COM */
|
||||||
if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) return "COM initialization failed";
|
if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) return "COM initialization failed";
|
||||||
|
|
|
@ -17,7 +17,7 @@ class MusicDriver_DMusic : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
virtual ~MusicDriver_DMusic();
|
virtual ~MusicDriver_DMusic();
|
||||||
|
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
/** Factory for the midi player that uses external players. */
|
/** Factory for the midi player that uses external players. */
|
||||||
static FMusicDriver_ExtMidi iFMusicDriver_ExtMidi;
|
static FMusicDriver_ExtMidi iFMusicDriver_ExtMidi;
|
||||||
|
|
||||||
std::optional<std::string_view> MusicDriver_ExtMidi::Start(const StringList &parm)
|
std::optional<std::string_view> MusicDriver_ExtMidi::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
if (VideoDriver::GetInstance()->GetName() == "allegro" ||
|
if (VideoDriver::GetInstance()->GetName() == "allegro" ||
|
||||||
SoundDriver::GetInstance()->GetName() == "allegro") {
|
SoundDriver::GetInstance()->GetName() == "allegro") {
|
||||||
|
|
|
@ -22,7 +22,7 @@ private:
|
||||||
void DoStop();
|
void DoStop();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,11 @@ static void RenderMusicStream(int16_t *buffer, size_t samples)
|
||||||
fluid_synth_write_s16(_midi.synth, samples, buffer, 0, 2, buffer, 1, 2);
|
fluid_synth_write_s16(_midi.synth, samples, buffer, 0, 2, buffer, 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string_view> MusicDriver_FluidSynth::Start(const StringList ¶m)
|
std::optional<std::string_view> MusicDriver_FluidSynth::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
||||||
|
|
||||||
const char *sfont_name = GetDriverParam(param, "soundfont");
|
const char *sfont_name = GetDriverParam(parm, "soundfont");
|
||||||
int sfont_id;
|
int sfont_id;
|
||||||
|
|
||||||
Debug(driver, 1, "Fluidsynth: sf {}", sfont_name != nullptr ? sfont_name : "(null)");
|
Debug(driver, 1, "Fluidsynth: sf {}", sfont_name != nullptr ? sfont_name : "(null)");
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** Music driver making use of FluidSynth. */
|
/** Music driver making use of FluidSynth. */
|
||||||
class MusicDriver_FluidSynth : public MusicDriver {
|
class MusicDriver_FluidSynth : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The music player that does nothing. */
|
/** The music player that does nothing. */
|
||||||
class MusicDriver_Null : public MusicDriver {
|
class MusicDriver_Null : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList &) override { return std::nullopt; }
|
std::optional<std::string_view> Start(std::span<const std::string>) override { return std::nullopt; }
|
||||||
|
|
||||||
void Stop() override { }
|
void Stop() override { }
|
||||||
|
|
||||||
|
|
|
@ -367,7 +367,7 @@ void MusicDriver_Win32::SetVolume(uint8_t vol)
|
||||||
_midi.new_volume = vol;
|
_midi.new_volume = vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string_view> MusicDriver_Win32::Start(const StringList &parm)
|
std::optional<std::string_view> MusicDriver_Win32::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
Debug(driver, 2, "Win32-MIDI: Start: initializing");
|
Debug(driver, 2, "Win32-MIDI: Start: initializing");
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The Windows music player. */
|
/** The Windows music player. */
|
||||||
class MusicDriver_Win32 : public MusicDriver {
|
class MusicDriver_Win32 : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ void SoundDriver_Allegro::MainLoop()
|
||||||
*/
|
*/
|
||||||
extern int _allegro_instance_count;
|
extern int _allegro_instance_count;
|
||||||
|
|
||||||
std::optional<std::string_view> SoundDriver_Allegro::Start(const StringList &parm)
|
std::optional<std::string_view> SoundDriver_Allegro::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
|
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
|
||||||
Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error);
|
Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** Implementation of the allegro sound driver. */
|
/** Implementation of the allegro sound driver. */
|
||||||
class SoundDriver_Allegro : public SoundDriver {
|
class SoundDriver_Allegro : public SoundDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ static OSStatus audioCallback(void *, AudioUnitRenderActionFlags *, const AudioT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::optional<std::string_view> SoundDriver_Cocoa::Start(const StringList &parm)
|
std::optional<std::string_view> SoundDriver_Cocoa::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
struct AURenderCallbackStruct callback;
|
struct AURenderCallbackStruct callback;
|
||||||
AudioStreamBasicDescription requestedDesc;
|
AudioStreamBasicDescription requestedDesc;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
class SoundDriver_Cocoa : public SoundDriver {
|
class SoundDriver_Cocoa : public SoundDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
std::string_view GetName() const override { return "cocoa"; }
|
std::string_view GetName() const override { return "cocoa"; }
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** Implementation of the null sound driver. */
|
/** Implementation of the null sound driver. */
|
||||||
class SoundDriver_Null : public SoundDriver {
|
class SoundDriver_Null : public SoundDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList &) override { return std::nullopt; }
|
std::optional<std::string_view> Start(std::span<const std::string>) override { return std::nullopt; }
|
||||||
|
|
||||||
void Stop() override { }
|
void Stop() override { }
|
||||||
std::string_view GetName() const override { return "null"; }
|
std::string_view GetName() const override { return "null"; }
|
||||||
|
|
|
@ -30,7 +30,7 @@ static void CDECL fill_sound_buffer(void *, Uint8 *stream, int len)
|
||||||
MxMixSamples(stream, len / 4);
|
MxMixSamples(stream, len / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string_view> SoundDriver_SDL::Start(const StringList &parm)
|
std::optional<std::string_view> SoundDriver_SDL::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
SDL_AudioSpec spec_actual;
|
SDL_AudioSpec spec_actual;
|
||||||
|
|
|
@ -30,7 +30,7 @@ static void CDECL fill_sound_buffer(void *, Uint8 *stream, int len)
|
||||||
MxMixSamples(stream, len / 4);
|
MxMixSamples(stream, len / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string_view> SoundDriver_SDL::Start(const StringList &parm)
|
std::optional<std::string_view> SoundDriver_SDL::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** Implementation of the SDL sound driver. */
|
/** Implementation of the SDL sound driver. */
|
||||||
class SoundDriver_SDL : public SoundDriver {
|
class SoundDriver_SDL : public SoundDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
std::string_view GetName() const override { return "sdl"; }
|
std::string_view GetName() const override { return "sdl"; }
|
||||||
|
|
|
@ -59,7 +59,7 @@ static DWORD WINAPI SoundThread(LPVOID)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string_view> SoundDriver_Win32::Start(const StringList &parm)
|
std::optional<std::string_view> SoundDriver_Win32::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
WAVEFORMATEX wfex;
|
WAVEFORMATEX wfex;
|
||||||
wfex.wFormatTag = WAVE_FORMAT_PCM;
|
wfex.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** Implementation of the sound driver for Windows. */
|
/** Implementation of the sound driver for Windows. */
|
||||||
class SoundDriver_Win32 : public SoundDriver {
|
class SoundDriver_Win32 : public SoundDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
std::string_view GetName() const override { return "win32"; }
|
std::string_view GetName() const override { return "win32"; }
|
||||||
|
|
|
@ -138,7 +138,7 @@ static HRESULT CreateXAudio(API_XAudio2Create xAudio2Create)
|
||||||
* @return An error message if unsuccessful, or std::nullopt otherwise.
|
* @return An error message if unsuccessful, or std::nullopt otherwise.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
std::optional<std::string_view> SoundDriver_XAudio2::Start(const StringList &parm)
|
std::optional<std::string_view> SoundDriver_XAudio2::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** Implementation of the XAudio2 sound driver. */
|
/** Implementation of the XAudio2 sound driver. */
|
||||||
class SoundDriver_XAudio2 : public SoundDriver {
|
class SoundDriver_XAudio2 : public SoundDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
std::string_view GetName() const override { return "xaudio2"; }
|
std::string_view GetName() const override { return "xaudio2"; }
|
||||||
|
|
|
@ -420,7 +420,7 @@ bool VideoDriver_Allegro::PollEvent()
|
||||||
*/
|
*/
|
||||||
int _allegro_instance_count = 0;
|
int _allegro_instance_count = 0;
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_Allegro::Start(const StringList ¶m)
|
std::optional<std::string_view> VideoDriver_Allegro::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
|
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
|
||||||
Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error);
|
Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error);
|
||||||
|
@ -448,7 +448,7 @@ std::optional<std::string_view> VideoDriver_Allegro::Start(const StringList &par
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
set_close_button_callback(HandleExitGameRequest);
|
set_close_button_callback(HandleExitGameRequest);
|
||||||
|
|
||||||
this->is_game_threaded = !GetDriverParamBool(param, "no_threads") && !GetDriverParamBool(param, "no_thread");
|
this->is_game_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The allegro video driver. */
|
/** The allegro video driver. */
|
||||||
class VideoDriver_Allegro : public VideoDriver {
|
class VideoDriver_Allegro : public VideoDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class VideoDriver_CocoaOpenGL : public VideoDriver_Cocoa {
|
||||||
public:
|
public:
|
||||||
VideoDriver_CocoaOpenGL() : VideoDriver_Cocoa(true), gl_context(nullptr), anim_buffer(nullptr), driver_info(this->GetName()) {}
|
VideoDriver_CocoaOpenGL() : VideoDriver_Cocoa(true), gl_context(nullptr), anim_buffer(nullptr), driver_info(this->GetName()) {}
|
||||||
|
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
bool HasEfficient8Bpp() const override { return true; }
|
bool HasEfficient8Bpp() const override { return true; }
|
||||||
|
|
|
@ -185,7 +185,7 @@ static bool _allowSoftware;
|
||||||
static FVideoDriver_CocoaOpenGL iFVideoDriver_CocoaOpenGL;
|
static FVideoDriver_CocoaOpenGL iFVideoDriver_CocoaOpenGL;
|
||||||
|
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_CocoaOpenGL::Start(const StringList ¶m)
|
std::optional<std::string_view> VideoDriver_CocoaOpenGL::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
auto err = this->Initialize();
|
auto err = this->Initialize();
|
||||||
if (err) return err;
|
if (err) return err;
|
||||||
|
|
|
@ -109,7 +109,7 @@ public:
|
||||||
|
|
||||||
VideoDriver_CocoaQuartz();
|
VideoDriver_CocoaQuartz();
|
||||||
|
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
/** Return driver name */
|
/** Return driver name */
|
||||||
|
|
|
@ -589,7 +589,7 @@ VideoDriver_CocoaQuartz::VideoDriver_CocoaQuartz()
|
||||||
this->cgcontext = nullptr;
|
this->cgcontext = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_CocoaQuartz::Start(const StringList ¶m)
|
std::optional<std::string_view> VideoDriver_CocoaQuartz::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
auto err = this->Initialize();
|
auto err = this->Initialize();
|
||||||
if (err) return err;
|
if (err) return err;
|
||||||
|
@ -613,7 +613,7 @@ std::optional<std::string_view> VideoDriver_CocoaQuartz::Start(const StringList
|
||||||
this->GameSizeChanged();
|
this->GameSizeChanged();
|
||||||
this->UpdateVideoModes();
|
this->UpdateVideoModes();
|
||||||
|
|
||||||
this->is_game_threaded = !GetDriverParamBool(param, "no_threads") && !GetDriverParamBool(param, "no_thread");
|
this->is_game_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ extern bool SafeLoad(const std::string &filename, SaveLoadOperation fop, Detaile
|
||||||
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
|
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
|
||||||
|
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_Dedicated::Start(const StringList &)
|
std::optional<std::string_view> VideoDriver_Dedicated::Start(std::span<const std::string>)
|
||||||
{
|
{
|
||||||
this->UpdateAutoResolution();
|
this->UpdateAutoResolution();
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The dedicated server video driver. */
|
/** The dedicated server video driver. */
|
||||||
class VideoDriver_Dedicated : public VideoDriver {
|
class VideoDriver_Dedicated : public VideoDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
/** Factory for the null video driver. */
|
/** Factory for the null video driver. */
|
||||||
static FVideoDriver_Null iFVideoDriver_Null;
|
static FVideoDriver_Null iFVideoDriver_Null;
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_Null::Start(const StringList &parm)
|
std::optional<std::string_view> VideoDriver_Null::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
/* Disable the MSVC assertion message box. */
|
/* Disable the MSVC assertion message box. */
|
||||||
|
|
|
@ -18,7 +18,7 @@ private:
|
||||||
uint ticks; ///< Amount of ticks to run.
|
uint ticks; ///< Amount of ticks to run.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,9 @@ bool VideoDriver_SDL_OpenGL::CreateMainWindow(uint w, uint h, uint flags)
|
||||||
return this->VideoDriver_SDL_Base::CreateMainWindow(w, h, flags | SDL_WINDOW_OPENGL);
|
return this->VideoDriver_SDL_Base::CreateMainWindow(w, h, flags | SDL_WINDOW_OPENGL);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_SDL_OpenGL::Start(const StringList ¶m)
|
std::optional<std::string_view> VideoDriver_SDL_OpenGL::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
auto error = VideoDriver_SDL_Base::Start(param);
|
auto error = VideoDriver_SDL_Base::Start(parm);
|
||||||
if (error) return error;
|
if (error) return error;
|
||||||
|
|
||||||
error = this->AllocateContext();
|
error = this->AllocateContext();
|
||||||
|
|
|
@ -14,7 +14,7 @@ class VideoDriver_SDL_OpenGL : public VideoDriver_SDL_Base {
|
||||||
public:
|
public:
|
||||||
VideoDriver_SDL_OpenGL() : VideoDriver_SDL_Base(true), gl_context(nullptr), anim_buffer(nullptr) {}
|
VideoDriver_SDL_OpenGL() : VideoDriver_SDL_Base(true), gl_context(nullptr), anim_buffer(nullptr) {}
|
||||||
|
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -540,7 +540,7 @@ std::optional<std::string_view> VideoDriver_SDL_Base::Initialize()
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_SDL_Base::Start(const StringList ¶m)
|
std::optional<std::string_view> VideoDriver_SDL_Base::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
|
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ std::optional<std::string_view> VideoDriver_SDL_Base::Start(const StringList &pa
|
||||||
if (error) return error;
|
if (error) return error;
|
||||||
|
|
||||||
#ifdef SDL_HINT_MOUSE_AUTO_CAPTURE
|
#ifdef SDL_HINT_MOUSE_AUTO_CAPTURE
|
||||||
if (GetDriverParamBool(param, "no_mouse_capture")) {
|
if (GetDriverParamBool(parm, "no_mouse_capture")) {
|
||||||
/* By default SDL captures the mouse, while a button is pressed.
|
/* By default SDL captures the mouse, while a button is pressed.
|
||||||
* This is annoying during debugging, when OpenTTD is suspended while the button was pressed.
|
* This is annoying during debugging, when OpenTTD is suspended while the button was pressed.
|
||||||
*/
|
*/
|
||||||
|
@ -560,7 +560,7 @@ std::optional<std::string_view> VideoDriver_SDL_Base::Start(const StringList &pa
|
||||||
SDL_SetHint(SDL_HINT_APP_NAME, "OpenTTD");
|
SDL_SetHint(SDL_HINT_APP_NAME, "OpenTTD");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->startup_display = FindStartupDisplay(GetDriverParamInt(param, "display", -1));
|
this->startup_display = FindStartupDisplay(GetDriverParamInt(parm, "display", -1));
|
||||||
|
|
||||||
if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height, false)) {
|
if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height, false)) {
|
||||||
return SDL_GetError();
|
return SDL_GetError();
|
||||||
|
@ -582,7 +582,7 @@ std::optional<std::string_view> VideoDriver_SDL_Base::Start(const StringList &pa
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
this->is_game_threaded = false;
|
this->is_game_threaded = false;
|
||||||
#else
|
#else
|
||||||
this->is_game_threaded = !GetDriverParamBool(param, "no_threads") && !GetDriverParamBool(param, "no_thread");
|
this->is_game_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
|
@ -19,7 +19,7 @@ class VideoDriver_SDL_Base : public VideoDriver {
|
||||||
public:
|
public:
|
||||||
VideoDriver_SDL_Base(bool uses_hardware_acceleration = false) : VideoDriver(uses_hardware_acceleration), sdl_window(nullptr), buffer_locked(false) {}
|
VideoDriver_SDL_Base(bool uses_hardware_acceleration = false) : VideoDriver(uses_hardware_acceleration), sdl_window(nullptr), buffer_locked(false) {}
|
||||||
|
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -582,7 +582,7 @@ bool VideoDriver_SDL::PollEvent()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_SDL::Start(const StringList ¶m)
|
std::optional<std::string_view> VideoDriver_SDL::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
char buf[30];
|
char buf[30];
|
||||||
_use_hwpalette = GetDriverParamInt(param, "hw_palette", 2);
|
_use_hwpalette = GetDriverParamInt(param, "hw_palette", 2);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The SDL video driver. */
|
/** The SDL video driver. */
|
||||||
class VideoDriver_SDL : public VideoDriver {
|
class VideoDriver_SDL : public VideoDriver {
|
||||||
public:
|
public:
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -1030,7 +1030,7 @@ void VideoDriver_Win32Base::UnlockVideoBuffer()
|
||||||
|
|
||||||
static FVideoDriver_Win32GDI iFVideoDriver_Win32GDI;
|
static FVideoDriver_Win32GDI iFVideoDriver_Win32GDI;
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_Win32GDI::Start(const StringList ¶m)
|
std::optional<std::string_view> VideoDriver_Win32GDI::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
|
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
|
||||||
|
|
||||||
|
@ -1042,7 +1042,7 @@ std::optional<std::string_view> VideoDriver_Win32GDI::Start(const StringList &pa
|
||||||
|
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
|
||||||
this->is_game_threaded = !GetDriverParamBool(param, "no_threads") && !GetDriverParamBool(param, "no_thread");
|
this->is_game_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
@ -1320,7 +1320,7 @@ static void LoadWGLExtensions()
|
||||||
|
|
||||||
static FVideoDriver_Win32OpenGL iFVideoDriver_Win32OpenGL;
|
static FVideoDriver_Win32OpenGL iFVideoDriver_Win32OpenGL;
|
||||||
|
|
||||||
std::optional<std::string_view> VideoDriver_Win32OpenGL::Start(const StringList ¶m)
|
std::optional<std::string_view> VideoDriver_Win32OpenGL::Start(std::span<const std::string> parm)
|
||||||
{
|
{
|
||||||
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
|
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
|
||||||
|
|
||||||
|
@ -1356,7 +1356,7 @@ std::optional<std::string_view> VideoDriver_Win32OpenGL::Start(const StringList
|
||||||
|
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
|
||||||
this->is_game_threaded = !GetDriverParamBool(param, "no_threads") && !GetDriverParamBool(param, "no_thread");
|
this->is_game_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ class VideoDriver_Win32GDI : public VideoDriver_Win32Base {
|
||||||
public:
|
public:
|
||||||
VideoDriver_Win32GDI() : dib_sect(nullptr), gdi_palette(nullptr), buffer_bits(nullptr) {}
|
VideoDriver_Win32GDI() : dib_sect(nullptr), gdi_palette(nullptr), buffer_bits(nullptr) {}
|
||||||
|
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class VideoDriver_Win32OpenGL : public VideoDriver_Win32Base {
|
||||||
public:
|
public:
|
||||||
VideoDriver_Win32OpenGL() : VideoDriver_Win32Base(true), dc(nullptr), gl_rc(nullptr), anim_buffer(nullptr), driver_info(this->GetName()) {}
|
VideoDriver_Win32OpenGL() : VideoDriver_Win32Base(true), dc(nullptr), gl_rc(nullptr), anim_buffer(nullptr), driver_info(this->GetName()) {}
|
||||||
|
|
||||||
std::optional<std::string_view> Start(const StringList ¶m) override;
|
std::optional<std::string_view> Start(std::span<const std::string> parm) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue