Codechange: Use std::string in the driver and blitter selection code.

This commit is contained in:
Michael Lutz
2020-05-17 23:32:08 +02:00
parent a49fdb7ebb
commit 37bc2f8064
51 changed files with 126 additions and 166 deletions

View File

@@ -410,7 +410,7 @@ static void PollEvent()
*/
int _allegro_instance_count = 0;
const char *VideoDriver_Allegro::Start(const char * const *parm)
const char *VideoDriver_Allegro::Start(const StringList &parm)
{
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);

View File

@@ -15,7 +15,7 @@
/** The allegro video driver. */
class VideoDriver_Allegro : public VideoDriver {
public:
const char *Start(const char * const *param) override;
const char *Start(const StringList &param) override;
void Stop() override;

View File

@@ -14,7 +14,7 @@
class VideoDriver_Cocoa : public VideoDriver {
public:
const char *Start(const char * const *param) override;
const char *Start(const StringList &param) override;
/** Stop the video driver */
void Stop() override;

View File

@@ -396,7 +396,7 @@ void VideoDriver_Cocoa::Stop()
/**
* Initialize a cocoa video subdriver.
*/
const char *VideoDriver_Cocoa::Start(const char * const *parm)
const char *VideoDriver_Cocoa::Start(const StringList &parm)
{
if (!MacOSVersionIsAtLeast(10, 6, 0)) return "The Cocoa video driver requires Mac OS X 10.6 or later.";
@@ -520,7 +520,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
bool wasstarted = _cocoa_video_started;
if (VideoDriver::GetInstance() == NULL) {
setupApplication(); // Setup application before showing dialog
} else if (!_cocoa_video_started && VideoDriver::GetInstance()->Start(NULL) != NULL) {
} else if (!_cocoa_video_started && VideoDriver::GetInstance()->Start(StringList()) != NULL) {
fprintf(stderr, "%s: %s\n", title, message);
return;
}

View File

@@ -133,7 +133,7 @@ extern bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileTy
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
const char *VideoDriver_Dedicated::Start(const char * const *parm)
const char *VideoDriver_Dedicated::Start(const StringList &parm)
{
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
_dedicated_video_mem = (bpp == 0) ? nullptr : MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8));

View File

@@ -15,7 +15,7 @@
/** The dedicated server video driver. */
class VideoDriver_Dedicated : public VideoDriver {
public:
const char *Start(const char * const *param) override;
const char *Start(const StringList &param) override;
void Stop() override;

View File

@@ -17,7 +17,7 @@
/** Factory for the null video driver. */
static FVideoDriver_Null iFVideoDriver_Null;
const char *VideoDriver_Null::Start(const char * const *parm)
const char *VideoDriver_Null::Start(const StringList &parm)
{
#ifdef _MSC_VER
/* Disable the MSVC assertion message box. */

View File

@@ -18,7 +18,7 @@ private:
uint ticks; ///< Amount of ticks to run.
public:
const char *Start(const char * const *param) override;
const char *Start(const StringList &param) override;
void Stop() override;

View File

@@ -626,7 +626,7 @@ int VideoDriver_SDL::PollEvent()
return -1;
}
const char *VideoDriver_SDL::Start(const char * const *parm)
const char *VideoDriver_SDL::Start(const StringList &parm)
{
/* Explicitly disable hardware acceleration. Enabling this causes
* UpdateWindowSurface() to update the window's texture instead of
@@ -652,7 +652,7 @@ const char *VideoDriver_SDL::Start(const char * const *parm)
MarkWholeScreenDirty();
_draw_threaded = GetDriverParam(parm, "no_threads") == nullptr && GetDriverParam(parm, "no_thread") == nullptr;
_draw_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
SDL_StopTextInput();
this->edit_box_focused = false;

View File

@@ -15,7 +15,7 @@
/** The SDL video driver. */
class VideoDriver_SDL : public VideoDriver {
public:
const char *Start(const char * const *param) override;
const char *Start(const StringList &param) override;
void Stop() override;

View File

@@ -596,7 +596,7 @@ int VideoDriver_SDL::PollEvent()
return -1;
}
const char *VideoDriver_SDL::Start(const char * const *parm)
const char *VideoDriver_SDL::Start(const StringList &parm)
{
char buf[30];
_use_hwpalette = GetDriverParamInt(parm, "hw_palette", 2);
@@ -623,7 +623,7 @@ const char *VideoDriver_SDL::Start(const char * const *parm)
MarkWholeScreenDirty();
SetupKeyboard();
_draw_threaded = GetDriverParam(parm, "no_threads") == nullptr && GetDriverParam(parm, "no_thread") == nullptr;
_draw_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
return nullptr;
}

View File

@@ -15,7 +15,7 @@
/** The SDL video driver. */
class VideoDriver_SDL : public VideoDriver {
public:
const char *Start(const char * const *param) override;
const char *Start(const StringList &param) override;
void Stop() override;

View File

@@ -104,7 +104,7 @@ public:
}
};
extern char *_ini_videodriver;
extern std::string _ini_videodriver;
extern std::vector<Dimension> _resolutions;
extern Dimension _cur_resolution;
extern bool _rightclick_emulate;

View File

@@ -1111,7 +1111,7 @@ static void FindResolutions()
static FVideoDriver_Win32 iFVideoDriver_Win32;
const char *VideoDriver_Win32::Start(const char * const *parm)
const char *VideoDriver_Win32::Start(const StringList &parm)
{
memset(&_wnd, 0, sizeof(_wnd));
@@ -1132,7 +1132,7 @@ const char *VideoDriver_Win32::Start(const char * const *parm)
MarkWholeScreenDirty();
_draw_threaded = GetDriverParam(parm, "no_threads") == nullptr && GetDriverParam(parm, "no_thread") == nullptr && std::thread::hardware_concurrency() > 1;
_draw_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread") && std::thread::hardware_concurrency() > 1;
return nullptr;
}

View File

@@ -15,7 +15,7 @@
/** The video driver for windows. */
class VideoDriver_Win32 : public VideoDriver {
public:
const char *Start(const char * const *param) override;
const char *Start(const StringList &param) override;
void Stop() override;