mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Use std::string in the driver and blitter selection code.
This commit is contained in:
parent
a49fdb7ebb
commit
37bc2f8064
|
@ -22,10 +22,10 @@
|
||||||
*/
|
*/
|
||||||
class BlitterFactory {
|
class BlitterFactory {
|
||||||
private:
|
private:
|
||||||
const char *name; ///< The name of the blitter factory.
|
const std::string name; ///< The name of the blitter factory.
|
||||||
const char *description; ///< The description of the blitter.
|
const std::string description; ///< The description of the blitter.
|
||||||
|
|
||||||
typedef std::map<const char *, BlitterFactory *, StringCompare> Blitters; ///< Map of blitter factories.
|
typedef std::map<std::string, BlitterFactory *> Blitters; ///< Map of blitter factories.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the map with currently known blitters.
|
* Get the map with currently known blitters.
|
||||||
|
@ -58,7 +58,7 @@ protected:
|
||||||
* @pre There is no blitter registered with this name.
|
* @pre There is no blitter registered with this name.
|
||||||
*/
|
*/
|
||||||
BlitterFactory(const char *name, const char *description, bool usable = true) :
|
BlitterFactory(const char *name, const char *description, bool usable = true) :
|
||||||
name(stredup(name)), description(stredup(description))
|
name(name), description(description)
|
||||||
{
|
{
|
||||||
if (usable) {
|
if (usable) {
|
||||||
/*
|
/*
|
||||||
|
@ -78,9 +78,6 @@ public:
|
||||||
{
|
{
|
||||||
GetBlitters().erase(this->name);
|
GetBlitters().erase(this->name);
|
||||||
if (GetBlitters().empty()) delete &GetBlitters();
|
if (GetBlitters().empty()) delete &GetBlitters();
|
||||||
|
|
||||||
free(this->name);
|
|
||||||
free(this->description);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +85,7 @@ public:
|
||||||
* @param name the blitter to select.
|
* @param name the blitter to select.
|
||||||
* @post Sets the blitter so GetCurrentBlitter() returns it too.
|
* @post Sets the blitter so GetCurrentBlitter() returns it too.
|
||||||
*/
|
*/
|
||||||
static Blitter *SelectBlitter(const char *name)
|
static Blitter *SelectBlitter(const std::string &name)
|
||||||
{
|
{
|
||||||
BlitterFactory *b = GetBlitterFactory(name);
|
BlitterFactory *b = GetBlitterFactory(name);
|
||||||
if (b == nullptr) return nullptr;
|
if (b == nullptr) return nullptr;
|
||||||
|
@ -97,7 +94,7 @@ public:
|
||||||
delete *GetActiveBlitter();
|
delete *GetActiveBlitter();
|
||||||
*GetActiveBlitter() = newb;
|
*GetActiveBlitter() = newb;
|
||||||
|
|
||||||
DEBUG(driver, 1, "Successfully %s blitter '%s'", StrEmpty(name) ? "probed" : "loaded", newb->GetName());
|
DEBUG(driver, 1, "Successfully %s blitter '%s'", name.empty() ? "probed" : "loaded", newb->GetName());
|
||||||
return newb;
|
return newb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +103,7 @@ public:
|
||||||
* @param name the blitter factory to select.
|
* @param name the blitter factory to select.
|
||||||
* @return The blitter factory, or nullptr when there isn't one with the wanted name.
|
* @return The blitter factory, or nullptr when there isn't one with the wanted name.
|
||||||
*/
|
*/
|
||||||
static BlitterFactory *GetBlitterFactory(const char *name)
|
static BlitterFactory *GetBlitterFactory(const std::string &name)
|
||||||
{
|
{
|
||||||
#if defined(DEDICATED)
|
#if defined(DEDICATED)
|
||||||
const char *default_blitter = "null";
|
const char *default_blitter = "null";
|
||||||
|
@ -116,12 +113,12 @@ public:
|
||||||
const char *default_blitter = "8bpp-optimized";
|
const char *default_blitter = "8bpp-optimized";
|
||||||
#endif
|
#endif
|
||||||
if (GetBlitters().size() == 0) return nullptr;
|
if (GetBlitters().size() == 0) return nullptr;
|
||||||
const char *bname = (StrEmpty(name)) ? default_blitter : name;
|
const char *bname = name.empty() ? default_blitter : name.c_str();
|
||||||
|
|
||||||
Blitters::iterator it = GetBlitters().begin();
|
Blitters::iterator it = GetBlitters().begin();
|
||||||
for (; it != GetBlitters().end(); it++) {
|
for (; it != GetBlitters().end(); it++) {
|
||||||
BlitterFactory *b = (*it).second;
|
BlitterFactory *b = (*it).second;
|
||||||
if (strcasecmp(bname, b->name) == 0) {
|
if (strcasecmp(bname, b->name.c_str()) == 0) {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +145,7 @@ public:
|
||||||
Blitters::iterator it = GetBlitters().begin();
|
Blitters::iterator it = GetBlitters().begin();
|
||||||
for (; it != GetBlitters().end(); it++) {
|
for (; it != GetBlitters().end(); it++) {
|
||||||
BlitterFactory *b = (*it).second;
|
BlitterFactory *b = (*it).second;
|
||||||
p += seprintf(p, last, "%18s: %s\n", b->name, b->GetDescription());
|
p += seprintf(p, last, "%18s: %s\n", b->name.c_str(), b->GetDescription().c_str());
|
||||||
}
|
}
|
||||||
p += seprintf(p, last, "\n");
|
p += seprintf(p, last, "\n");
|
||||||
|
|
||||||
|
@ -158,7 +155,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Get the long, human readable, name for the Blitter-class.
|
* Get the long, human readable, name for the Blitter-class.
|
||||||
*/
|
*/
|
||||||
const char *GetName() const
|
const std::string &GetName() const
|
||||||
{
|
{
|
||||||
return this->name;
|
return this->name;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +163,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Get a nice description of the blitter-class.
|
* Get a nice description of the blitter-class.
|
||||||
*/
|
*/
|
||||||
const char *GetDescription() const
|
const std::string &GetDescription() const
|
||||||
{
|
{
|
||||||
return this->description;
|
return this->description;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +174,7 @@ public:
|
||||||
virtual Blitter *CreateInstance() = 0;
|
virtual Blitter *CreateInstance() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char *_ini_blitter;
|
extern std::string _ini_blitter;
|
||||||
extern bool _blitter_autodetected;
|
extern bool _blitter_autodetected;
|
||||||
|
|
||||||
#endif /* BLITTER_FACTORY_HPP */
|
#endif /* BLITTER_FACTORY_HPP */
|
||||||
|
|
|
@ -13,19 +13,21 @@
|
||||||
#include "music/music_driver.hpp"
|
#include "music/music_driver.hpp"
|
||||||
#include "video/video_driver.hpp"
|
#include "video/video_driver.hpp"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
char *_ini_videodriver; ///< The video driver a stored in the configuration file.
|
std::string _ini_videodriver; ///< The video driver a stored in the configuration file.
|
||||||
std::vector<Dimension> _resolutions; ///< List of resolutions.
|
std::vector<Dimension> _resolutions; ///< List of resolutions.
|
||||||
Dimension _cur_resolution; ///< The current resolution.
|
Dimension _cur_resolution; ///< The current resolution.
|
||||||
bool _rightclick_emulate; ///< Whether right clicking is emulated.
|
bool _rightclick_emulate; ///< Whether right clicking is emulated.
|
||||||
|
|
||||||
char *_ini_sounddriver; ///< The sound driver a stored in the configuration file.
|
std::string _ini_sounddriver; ///< The sound driver a stored in the configuration file.
|
||||||
|
|
||||||
char *_ini_musicdriver; ///< The music driver a stored in the configuration file.
|
std::string _ini_musicdriver; ///< The music driver a stored in the configuration file.
|
||||||
|
|
||||||
char *_ini_blitter; ///< The blitter as stored in the configuration file.
|
std::string _ini_blitter; ///< The blitter as stored in the configuration file.
|
||||||
bool _blitter_autodetected; ///< Was the blitter autodetected or specified by the user?
|
bool _blitter_autodetected; ///< Was the blitter autodetected or specified by the user?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,19 +36,15 @@ bool _blitter_autodetected; ///< Was the blitter autodetected or specif
|
||||||
* @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 char * const *parm, const char *name)
|
const char *GetDriverParam(const StringList &parm, const char *name)
|
||||||
{
|
{
|
||||||
size_t len;
|
if (parm.empty()) return nullptr;
|
||||||
|
|
||||||
if (parm == nullptr) return nullptr;
|
size_t len = strlen(name);
|
||||||
|
for (auto &p : parm) {
|
||||||
len = strlen(name);
|
if (p.compare(0, len, name) == 0) {
|
||||||
for (; *parm != nullptr; parm++) {
|
if (p.length() == len) return "";
|
||||||
const char *p = *parm;
|
if (p[len] == '=') return p.c_str() + len + 1;
|
||||||
|
|
||||||
if (strncmp(p, name, len) == 0) {
|
|
||||||
if (p[len] == '=') return p + len + 1;
|
|
||||||
if (p[len] == '\0') return p + len;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -58,7 +56,7 @@ const char *GetDriverParam(const char * const *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 char * const *parm, const char *name)
|
bool GetDriverParamBool(const StringList &parm, const char *name)
|
||||||
{
|
{
|
||||||
return GetDriverParam(parm, name) != nullptr;
|
return GetDriverParam(parm, name) != nullptr;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +68,7 @@ bool GetDriverParamBool(const char * const *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 char * const *parm, const char *name, int def)
|
int GetDriverParamInt(const StringList &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;
|
||||||
|
@ -82,12 +80,12 @@ int GetDriverParamInt(const char * const *parm, const char *name, int def)
|
||||||
* @param type the type of driver to select
|
* @param type the type of driver to select
|
||||||
* @post Sets the driver so GetCurrentDriver() returns it too.
|
* @post Sets the driver so GetCurrentDriver() returns it too.
|
||||||
*/
|
*/
|
||||||
void DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
|
void DriverFactoryBase::SelectDriver(const std::string &name, Driver::Type type)
|
||||||
{
|
{
|
||||||
if (!DriverFactoryBase::SelectDriverImpl(name, type)) {
|
if (!DriverFactoryBase::SelectDriverImpl(name, type)) {
|
||||||
StrEmpty(name) ?
|
name.empty() ?
|
||||||
usererror("Failed to autoprobe %s driver", GetDriverTypeName(type)) :
|
usererror("Failed to autoprobe %s driver", GetDriverTypeName(type)) :
|
||||||
usererror("Failed to select requested %s driver '%s'", GetDriverTypeName(type), name);
|
usererror("Failed to select requested %s driver '%s'", GetDriverTypeName(type), name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +96,11 @@ void DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
|
||||||
* @post Sets the driver so GetCurrentDriver() returns it too.
|
* @post Sets the driver so GetCurrentDriver() returns it too.
|
||||||
* @return True upon success, otherwise false.
|
* @return True upon success, otherwise false.
|
||||||
*/
|
*/
|
||||||
bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
|
bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type type)
|
||||||
{
|
{
|
||||||
if (GetDrivers().size() == 0) return false;
|
if (GetDrivers().size() == 0) return false;
|
||||||
|
|
||||||
if (StrEmpty(name)) {
|
if (name.empty()) {
|
||||||
/* Probe for this driver, but do not fall back to dedicated/null! */
|
/* Probe for this driver, but do not fall back to dedicated/null! */
|
||||||
for (int priority = 10; priority > 0; priority--) {
|
for (int priority = 10; priority > 0; priority--) {
|
||||||
Drivers::iterator it = GetDrivers().begin();
|
Drivers::iterator it = GetDrivers().begin();
|
||||||
|
@ -117,7 +115,7 @@ bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
|
||||||
Driver *newd = d->CreateInstance();
|
Driver *newd = d->CreateInstance();
|
||||||
*GetActiveDriver(type) = newd;
|
*GetActiveDriver(type) = newd;
|
||||||
|
|
||||||
const char *err = newd->Start(nullptr);
|
const char *err = newd->Start({});
|
||||||
if (err == nullptr) {
|
if (err == nullptr) {
|
||||||
DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
|
DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
|
||||||
delete oldd;
|
delete oldd;
|
||||||
|
@ -131,23 +129,15 @@ bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
|
||||||
}
|
}
|
||||||
usererror("Couldn't find any suitable %s driver", GetDriverTypeName(type));
|
usererror("Couldn't find any suitable %s driver", GetDriverTypeName(type));
|
||||||
} else {
|
} else {
|
||||||
char *parm;
|
|
||||||
char buffer[256];
|
|
||||||
const char *parms[32];
|
|
||||||
|
|
||||||
/* Extract the driver name and put parameter list in parm */
|
/* Extract the driver name and put parameter list in parm */
|
||||||
strecpy(buffer, name, lastof(buffer));
|
std::istringstream buffer(name);
|
||||||
parm = strchr(buffer, ':');
|
std::string dname;
|
||||||
parms[0] = nullptr;
|
std::getline(buffer, dname, ':');
|
||||||
if (parm != nullptr) {
|
|
||||||
uint np = 0;
|
std::string param;
|
||||||
/* Tokenize the parm. */
|
std::vector<std::string> parms;
|
||||||
do {
|
while (std::getline(buffer, param, ',')) {
|
||||||
*parm++ = '\0';
|
parms.push_back(param);
|
||||||
if (np < lengthof(parms) - 1) parms[np++] = parm;
|
|
||||||
while (*parm != '\0' && *parm != ',') parm++;
|
|
||||||
} while (*parm == ',');
|
|
||||||
parms[np] = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find this driver */
|
/* Find this driver */
|
||||||
|
@ -159,7 +149,7 @@ bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
|
||||||
if (d->type != type) continue;
|
if (d->type != type) continue;
|
||||||
|
|
||||||
/* Check driver name */
|
/* Check driver name */
|
||||||
if (strcasecmp(buffer, d->name) != 0) continue;
|
if (strcasecmp(dname.c_str(), d->name) != 0) continue;
|
||||||
|
|
||||||
/* Found our driver, let's try it */
|
/* Found our driver, let's try it */
|
||||||
Driver *newd = d->CreateInstance();
|
Driver *newd = d->CreateInstance();
|
||||||
|
@ -175,7 +165,7 @@ bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
|
||||||
*GetActiveDriver(type) = newd;
|
*GetActiveDriver(type) = newd;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
usererror("No such %s driver: %s\n", GetDriverTypeName(type), buffer);
|
usererror("No such %s driver: %s\n", GetDriverTypeName(type), dname.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,9 +211,7 @@ DriverFactoryBase::DriverFactoryBase(Driver::Type type, int priority, const char
|
||||||
strecpy(buf, GetDriverTypeName(type), lastof(buf));
|
strecpy(buf, GetDriverTypeName(type), lastof(buf));
|
||||||
strecpy(buf + 5, name, lastof(buf));
|
strecpy(buf + 5, name, lastof(buf));
|
||||||
|
|
||||||
const char *longname = stredup(buf);
|
std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(buf, this));
|
||||||
|
|
||||||
std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(longname, this));
|
|
||||||
assert(P.second);
|
assert(P.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,10 +228,6 @@ DriverFactoryBase::~DriverFactoryBase()
|
||||||
Drivers::iterator it = GetDrivers().find(buf);
|
Drivers::iterator it = GetDrivers().find(buf);
|
||||||
assert(it != GetDrivers().end());
|
assert(it != GetDrivers().end());
|
||||||
|
|
||||||
const char *longname = (*it).first;
|
|
||||||
|
|
||||||
GetDrivers().erase(it);
|
GetDrivers().erase(it);
|
||||||
free(longname);
|
|
||||||
|
|
||||||
if (GetDrivers().empty()) delete &GetDrivers();
|
if (GetDrivers().empty()) delete &GetDrivers();
|
||||||
}
|
}
|
||||||
|
|
15
src/driver.h
15
src/driver.h
|
@ -12,11 +12,12 @@
|
||||||
|
|
||||||
#include "core/enum_type.hpp"
|
#include "core/enum_type.hpp"
|
||||||
#include "core/string_compare_type.hpp"
|
#include "core/string_compare_type.hpp"
|
||||||
|
#include "string_type.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
const char *GetDriverParam(const char * const *parm, const char *name);
|
const char *GetDriverParam(const StringList &parm, const char *name);
|
||||||
bool GetDriverParamBool(const char * const *parm, const char *name);
|
bool GetDriverParamBool(const StringList &parm, const char *name);
|
||||||
int GetDriverParamInt(const char * const *parm, const char *name, int def);
|
int GetDriverParamInt(const StringList &parm, const char *name, int def);
|
||||||
|
|
||||||
/** A driver for communicating with the user. */
|
/** A driver for communicating with the user. */
|
||||||
class Driver {
|
class Driver {
|
||||||
|
@ -26,7 +27,7 @@ public:
|
||||||
* @param parm Parameters passed to the driver.
|
* @param parm Parameters passed to the driver.
|
||||||
* @return nullptr if everything went okay, otherwise an error message.
|
* @return nullptr if everything went okay, otherwise an error message.
|
||||||
*/
|
*/
|
||||||
virtual const char *Start(const char * const *parm) = 0;
|
virtual const char *Start(const StringList &parm) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop this driver.
|
* Stop this driver.
|
||||||
|
@ -66,7 +67,7 @@ private:
|
||||||
const char *name; ///< The name of the drivers of this factory.
|
const char *name; ///< The name of the drivers of this factory.
|
||||||
const char *description; ///< The description of this driver.
|
const char *description; ///< The description of this driver.
|
||||||
|
|
||||||
typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers; ///< Type for a map of drivers.
|
typedef std::map<std::string, DriverFactoryBase *> Drivers; ///< Type for a map of drivers.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the map with drivers.
|
* Get the map with drivers.
|
||||||
|
@ -99,7 +100,7 @@ private:
|
||||||
return driver_type_name[type];
|
return driver_type_name[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool SelectDriverImpl(const char *name, Driver::Type type);
|
static bool SelectDriverImpl(const std::string &name, Driver::Type type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description);
|
DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description);
|
||||||
|
@ -118,7 +119,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SelectDriver(const char *name, Driver::Type type);
|
static void SelectDriver(const std::string &name, Driver::Type type);
|
||||||
static char *GetDriversInfo(char *p, const char *last);
|
static char *GetDriversInfo(char *p, const char *last);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,7 +26,7 @@ static MIDI *_midi = nullptr;
|
||||||
*/
|
*/
|
||||||
extern int _allegro_instance_count;
|
extern int _allegro_instance_count;
|
||||||
|
|
||||||
const char *MusicDriver_Allegro::Start(const char * const *param)
|
const char *MusicDriver_Allegro::Start(const StringList ¶m)
|
||||||
{
|
{
|
||||||
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 '%s'", allegro_error);
|
DEBUG(driver, 0, "allegro: install_allegro failed '%s'", 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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ static BMidiSynthFile midiSynthFile;
|
||||||
/** Factory for BeOS' midi player. */
|
/** Factory for BeOS' midi player. */
|
||||||
static FMusicDriver_BeMidi iFMusicDriver_BeMidi;
|
static FMusicDriver_BeMidi iFMusicDriver_BeMidi;
|
||||||
|
|
||||||
const char *MusicDriver_BeMidi::Start(const char * const *parm)
|
const char *MusicDriver_BeMidi::Start(const StringList &parm)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The midi player for BeOS. */
|
/** The midi player for BeOS. */
|
||||||
class MusicDriver_BeMidi : public MusicDriver {
|
class MusicDriver_BeMidi : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) 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.
|
||||||
*/
|
*/
|
||||||
const char *MusicDriver_Cocoa::Start(const char * const *parm)
|
const char *MusicDriver_Cocoa::Start(const StringList &parm)
|
||||||
{
|
{
|
||||||
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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -1071,7 +1071,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *MusicDriver_DMusic::Start(const char * const *parm)
|
const char *MusicDriver_DMusic::Start(const StringList &parm)
|
||||||
{
|
{
|
||||||
/* Initialize COM */
|
/* Initialize COM */
|
||||||
if (FAILED(CoInitializeEx(nullptr, COINITBASE_MULTITHREADED))) return "COM initialization failed";
|
if (FAILED(CoInitializeEx(nullptr, COINITBASE_MULTITHREADED))) return "COM initialization failed";
|
||||||
|
|
|
@ -17,7 +17,7 @@ class MusicDriver_DMusic : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
virtual ~MusicDriver_DMusic();
|
virtual ~MusicDriver_DMusic();
|
||||||
|
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,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;
|
||||||
|
|
||||||
const char *MusicDriver_ExtMidi::Start(const char * const * parm)
|
const char *MusicDriver_ExtMidi::Start(const StringList &parm)
|
||||||
{
|
{
|
||||||
if (strcmp(VideoDriver::GetInstance()->GetName(), "allegro") == 0 ||
|
if (strcmp(VideoDriver::GetInstance()->GetName(), "allegro") == 0 ||
|
||||||
strcmp(SoundDriver::GetInstance()->GetName(), "allegro") == 0) {
|
strcmp(SoundDriver::GetInstance()->GetName(), "allegro") == 0) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ private:
|
||||||
void DoStop();
|
void DoStop();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ static void RenderMusicStream(int16 *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);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MusicDriver_FluidSynth::Start(const char * const *param)
|
const char *MusicDriver_FluidSynth::Start(const StringList ¶m)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
||||||
|
|
||||||
|
|
|
@ -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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char *_ini_musicdriver;
|
extern std::string _ini_musicdriver;
|
||||||
|
|
||||||
#endif /* MUSIC_MUSIC_DRIVER_HPP */
|
#endif /* MUSIC_MUSIC_DRIVER_HPP */
|
||||||
|
|
|
@ -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:
|
||||||
const char *Start(const char * const *param) override { return nullptr; }
|
const char *Start(const StringList ¶m) override { return nullptr; }
|
||||||
|
|
||||||
void Stop() override { }
|
void Stop() override { }
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ bool MusicDriver_OS2::IsSongPlaying()
|
||||||
return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
|
return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MusicDriver_OS2::Start(const char * const *parm)
|
const char *MusicDriver_OS2::Start(const StringList &parm)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** OS/2's music player. */
|
/** OS/2's music player. */
|
||||||
class MusicDriver_OS2 : public MusicDriver {
|
class MusicDriver_OS2 : public MusicDriver {
|
||||||
public:
|
public:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ void MusicDriver_Win32::SetVolume(byte vol)
|
||||||
_midi.new_volume = vol;
|
_midi.new_volume = vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MusicDriver_Win32::Start(const char * const *parm)
|
const char *MusicDriver_Win32::Start(const StringList &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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -533,10 +533,10 @@ static const OptionData _options[] = {
|
||||||
*/
|
*/
|
||||||
int openttd_main(int argc, char *argv[])
|
int openttd_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *musicdriver = nullptr;
|
std::string musicdriver;
|
||||||
char *sounddriver = nullptr;
|
std::string sounddriver;
|
||||||
char *videodriver = nullptr;
|
std::string videodriver;
|
||||||
char *blitter = nullptr;
|
std::string blitter;
|
||||||
std::string graphics_set;
|
std::string graphics_set;
|
||||||
std::string sounds_set;
|
std::string sounds_set;
|
||||||
std::string music_set;
|
std::string music_set;
|
||||||
|
@ -566,19 +566,15 @@ int openttd_main(int argc, char *argv[])
|
||||||
case 'I': graphics_set = mgo.opt; break;
|
case 'I': graphics_set = mgo.opt; break;
|
||||||
case 'S': sounds_set = mgo.opt; break;
|
case 'S': sounds_set = mgo.opt; break;
|
||||||
case 'M': music_set = mgo.opt; break;
|
case 'M': music_set = mgo.opt; break;
|
||||||
case 'm': free(musicdriver); musicdriver = stredup(mgo.opt); break;
|
case 'm': musicdriver = mgo.opt; break;
|
||||||
case 's': free(sounddriver); sounddriver = stredup(mgo.opt); break;
|
case 's': sounddriver = mgo.opt; break;
|
||||||
case 'v': free(videodriver); videodriver = stredup(mgo.opt); break;
|
case 'v': videodriver = mgo.opt; break;
|
||||||
case 'b': free(blitter); blitter = stredup(mgo.opt); break;
|
case 'b': blitter = mgo.opt; break;
|
||||||
case 'D':
|
case 'D':
|
||||||
free(musicdriver);
|
musicdriver = "null";
|
||||||
free(sounddriver);
|
sounddriver = "null";
|
||||||
free(videodriver);
|
videodriver = "dedicated";
|
||||||
free(blitter);
|
blitter = "null";
|
||||||
musicdriver = stredup("null");
|
|
||||||
sounddriver = stredup("null");
|
|
||||||
videodriver = stredup("dedicated");
|
|
||||||
blitter = stredup("null");
|
|
||||||
dedicated = true;
|
dedicated = true;
|
||||||
SetDebugString("net=6");
|
SetDebugString("net=6");
|
||||||
if (mgo.opt != nullptr) {
|
if (mgo.opt != nullptr) {
|
||||||
|
@ -746,8 +742,8 @@ int openttd_main(int argc, char *argv[])
|
||||||
GfxInitPalettes();
|
GfxInitPalettes();
|
||||||
|
|
||||||
DEBUG(misc, 1, "Loading blitter...");
|
DEBUG(misc, 1, "Loading blitter...");
|
||||||
if (blitter == nullptr && _ini_blitter != nullptr) blitter = stredup(_ini_blitter);
|
if (blitter.empty() && !_ini_blitter.empty()) blitter = _ini_blitter;
|
||||||
_blitter_autodetected = StrEmpty(blitter);
|
_blitter_autodetected = blitter.empty();
|
||||||
/* Activate the initial blitter.
|
/* Activate the initial blitter.
|
||||||
* This is only some initial guess, after NewGRFs have been loaded SwitchNewGRFBlitter may switch to a different one.
|
* This is only some initial guess, after NewGRFs have been loaded SwitchNewGRFBlitter may switch to a different one.
|
||||||
* - Never guess anything, if the user specified a blitter. (_blitter_autodetected)
|
* - Never guess anything, if the user specified a blitter. (_blitter_autodetected)
|
||||||
|
@ -758,16 +754,14 @@ int openttd_main(int argc, char *argv[])
|
||||||
(_support8bpp != S8BPP_NONE && (BaseGraphics::GetUsedSet() == nullptr || BaseGraphics::GetUsedSet()->blitter == BLT_8BPP)) ||
|
(_support8bpp != S8BPP_NONE && (BaseGraphics::GetUsedSet() == nullptr || BaseGraphics::GetUsedSet()->blitter == BLT_8BPP)) ||
|
||||||
BlitterFactory::SelectBlitter("32bpp-anim") == nullptr) {
|
BlitterFactory::SelectBlitter("32bpp-anim") == nullptr) {
|
||||||
if (BlitterFactory::SelectBlitter(blitter) == nullptr) {
|
if (BlitterFactory::SelectBlitter(blitter) == nullptr) {
|
||||||
StrEmpty(blitter) ?
|
blitter.empty() ?
|
||||||
usererror("Failed to autoprobe blitter") :
|
usererror("Failed to autoprobe blitter") :
|
||||||
usererror("Failed to select requested blitter '%s'; does it exist?", blitter);
|
usererror("Failed to select requested blitter '%s'; does it exist?", blitter.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(blitter);
|
|
||||||
|
|
||||||
if (videodriver == nullptr && _ini_videodriver != nullptr) videodriver = stredup(_ini_videodriver);
|
if (videodriver.empty() && !_ini_videodriver.empty()) videodriver = _ini_videodriver;
|
||||||
DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
|
DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
|
||||||
free(videodriver);
|
|
||||||
|
|
||||||
InitializeSpriteSorter();
|
InitializeSpriteSorter();
|
||||||
|
|
||||||
|
@ -824,13 +818,11 @@ int openttd_main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sounddriver == nullptr && _ini_sounddriver != nullptr) sounddriver = stredup(_ini_sounddriver);
|
if (sounddriver.empty() && !_ini_sounddriver.empty()) sounddriver = _ini_sounddriver;
|
||||||
DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
|
DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
|
||||||
free(sounddriver);
|
|
||||||
|
|
||||||
if (musicdriver == nullptr && _ini_musicdriver != nullptr) musicdriver = stredup(_ini_musicdriver);
|
if (musicdriver.empty() && !_ini_musicdriver.empty()) musicdriver = _ini_musicdriver;
|
||||||
DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
|
DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
|
||||||
free(musicdriver);
|
|
||||||
|
|
||||||
/* Take our initial lock on whatever we might want to do! */
|
/* Take our initial lock on whatever we might want to do! */
|
||||||
try {
|
try {
|
||||||
|
@ -868,23 +860,9 @@ int openttd_main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Reset windowing system, stop drivers, free used memory, ... */
|
/* Reset windowing system, stop drivers, free used memory, ... */
|
||||||
ShutdownGame();
|
ShutdownGame();
|
||||||
goto exit_normal;
|
|
||||||
|
|
||||||
exit_noshutdown:
|
exit_noshutdown:
|
||||||
/* These three are normally freed before bootstrap. */
|
|
||||||
free(videodriver);
|
|
||||||
free(blitter);
|
|
||||||
|
|
||||||
exit_bootstrap:
|
exit_bootstrap:
|
||||||
/* These are normally freed before exit, but after bootstrap. */
|
|
||||||
free(musicdriver);
|
|
||||||
free(sounddriver);
|
|
||||||
|
|
||||||
exit_normal:
|
|
||||||
free(_ini_musicdriver);
|
|
||||||
free(_ini_sounddriver);
|
|
||||||
free(_ini_videodriver);
|
|
||||||
free(_ini_blitter);
|
|
||||||
|
|
||||||
delete scanner;
|
delete scanner;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ void SoundDriver_Allegro::MainLoop()
|
||||||
*/
|
*/
|
||||||
extern int _allegro_instance_count;
|
extern int _allegro_instance_count;
|
||||||
|
|
||||||
const char *SoundDriver_Allegro::Start(const char * const *parm)
|
const char *SoundDriver_Allegro::Start(const StringList &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 '%s'", allegro_error);
|
DEBUG(driver, 0, "allegro: install_allegro failed '%s'", 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:
|
||||||
const char *Start(const char * const *param);
|
const char *Start(const StringList ¶m);
|
||||||
|
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ static OSStatus audioCallback(void *inRefCon, AudioUnitRenderActionFlags *inActi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *SoundDriver_Cocoa::Start(const char * const *parm)
|
const char *SoundDriver_Cocoa::Start(const StringList &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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
const char *GetName() const override { return "cocoa"; }
|
const char *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:
|
||||||
const char *Start(const char * const *param) override { return nullptr; }
|
const char *Start(const StringList ¶m) override { return nullptr; }
|
||||||
|
|
||||||
void Stop() override { }
|
void Stop() override { }
|
||||||
const char *GetName() const override { return "null"; }
|
const char *GetName() const override { return "null"; }
|
||||||
|
|
|
@ -31,7 +31,7 @@ static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
|
||||||
MxMixSamples(stream, len / 4);
|
MxMixSamples(stream, len / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SoundDriver_SDL::Start(const char * const *parm)
|
const char *SoundDriver_SDL::Start(const StringList &parm)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
SDL_AudioSpec spec_actual;
|
SDL_AudioSpec spec_actual;
|
||||||
|
|
|
@ -31,7 +31,7 @@ static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
|
||||||
MxMixSamples(stream, len / 4);
|
MxMixSamples(stream, len / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SoundDriver_SDL::Start(const char * const *parm)
|
const char *SoundDriver_SDL::Start(const StringList &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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
const char *GetName() const override { return "sdl"; }
|
const char *GetName() const override { return "sdl"; }
|
||||||
|
|
|
@ -26,6 +26,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char *_ini_sounddriver;
|
extern std::string _ini_sounddriver;
|
||||||
|
|
||||||
#endif /* SOUND_SOUND_DRIVER_HPP */
|
#endif /* SOUND_SOUND_DRIVER_HPP */
|
||||||
|
|
|
@ -58,7 +58,7 @@ static DWORD WINAPI SoundThread(LPVOID arg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SoundDriver_Win32::Start(const char * const *parm)
|
const char *SoundDriver_Win32::Start(const StringList &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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
const char *GetName() const override { return "win32"; }
|
const char *GetName() const override { return "win32"; }
|
||||||
|
|
|
@ -126,7 +126,7 @@ static StreamingVoiceContext* _voice_context = nullptr;
|
||||||
* @return An error message if unsuccessful, or nullptr otherwise.
|
* @return An error message if unsuccessful, or nullptr otherwise.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const char *SoundDriver_XAudio2::Start(const char * const *parm)
|
const char *SoundDriver_XAudio2::Start(const StringList &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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
const char *GetName() const override { return "xaudio2"; }
|
const char *GetName() const override { return "xaudio2"; }
|
||||||
|
|
|
@ -80,28 +80,28 @@ var = BaseMusic::ini_set
|
||||||
def = nullptr
|
def = nullptr
|
||||||
cat = SC_BASIC
|
cat = SC_BASIC
|
||||||
|
|
||||||
[SDTG_STR]
|
[SDTG_SSTR]
|
||||||
name = ""videodriver""
|
name = ""videodriver""
|
||||||
type = SLE_STRQ
|
type = SLE_STRQ
|
||||||
var = _ini_videodriver
|
var = _ini_videodriver
|
||||||
def = nullptr
|
def = nullptr
|
||||||
cat = SC_EXPERT
|
cat = SC_EXPERT
|
||||||
|
|
||||||
[SDTG_STR]
|
[SDTG_SSTR]
|
||||||
name = ""musicdriver""
|
name = ""musicdriver""
|
||||||
type = SLE_STRQ
|
type = SLE_STRQ
|
||||||
var = _ini_musicdriver
|
var = _ini_musicdriver
|
||||||
def = nullptr
|
def = nullptr
|
||||||
cat = SC_EXPERT
|
cat = SC_EXPERT
|
||||||
|
|
||||||
[SDTG_STR]
|
[SDTG_SSTR]
|
||||||
name = ""sounddriver""
|
name = ""sounddriver""
|
||||||
type = SLE_STRQ
|
type = SLE_STRQ
|
||||||
var = _ini_sounddriver
|
var = _ini_sounddriver
|
||||||
def = nullptr
|
def = nullptr
|
||||||
cat = SC_EXPERT
|
cat = SC_EXPERT
|
||||||
|
|
||||||
[SDTG_STR]
|
[SDTG_SSTR]
|
||||||
name = ""blitter""
|
name = ""blitter""
|
||||||
type = SLE_STRQ
|
type = SLE_STRQ
|
||||||
var = _ini_blitter
|
var = _ini_blitter
|
||||||
|
|
|
@ -410,7 +410,7 @@ static void PollEvent()
|
||||||
*/
|
*/
|
||||||
int _allegro_instance_count = 0;
|
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)) {
|
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
|
||||||
DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
|
DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The allegro video driver. */
|
/** The allegro video driver. */
|
||||||
class VideoDriver_Allegro : public VideoDriver {
|
class VideoDriver_Allegro : public VideoDriver {
|
||||||
public:
|
public:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
class VideoDriver_Cocoa : public VideoDriver {
|
class VideoDriver_Cocoa : public VideoDriver {
|
||||||
public:
|
public:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
/** Stop the video driver */
|
/** Stop the video driver */
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
|
@ -396,7 +396,7 @@ void VideoDriver_Cocoa::Stop()
|
||||||
/**
|
/**
|
||||||
* Initialize a cocoa video subdriver.
|
* 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.";
|
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;
|
bool wasstarted = _cocoa_video_started;
|
||||||
if (VideoDriver::GetInstance() == NULL) {
|
if (VideoDriver::GetInstance() == NULL) {
|
||||||
setupApplication(); // Setup application before showing dialog
|
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);
|
fprintf(stderr, "%s: %s\n", title, message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ extern bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileTy
|
||||||
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
|
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();
|
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
|
||||||
_dedicated_video_mem = (bpp == 0) ? nullptr : MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8));
|
_dedicated_video_mem = (bpp == 0) ? nullptr : MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8));
|
||||||
|
|
|
@ -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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
/** Factory for the null video driver. */
|
/** Factory for the null video driver. */
|
||||||
static FVideoDriver_Null iFVideoDriver_Null;
|
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
|
#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:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -626,7 +626,7 @@ int VideoDriver_SDL::PollEvent()
|
||||||
return -1;
|
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
|
/* Explicitly disable hardware acceleration. Enabling this causes
|
||||||
* UpdateWindowSurface() to update the window's texture instead of
|
* UpdateWindowSurface() to update the window's texture instead of
|
||||||
|
@ -652,7 +652,7 @@ const char *VideoDriver_SDL::Start(const char * const *parm)
|
||||||
|
|
||||||
MarkWholeScreenDirty();
|
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();
|
SDL_StopTextInput();
|
||||||
this->edit_box_focused = false;
|
this->edit_box_focused = false;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The SDL video driver. */
|
/** The SDL video driver. */
|
||||||
class VideoDriver_SDL : public VideoDriver {
|
class VideoDriver_SDL : public VideoDriver {
|
||||||
public:
|
public:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -596,7 +596,7 @@ int VideoDriver_SDL::PollEvent()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *VideoDriver_SDL::Start(const char * const *parm)
|
const char *VideoDriver_SDL::Start(const StringList &parm)
|
||||||
{
|
{
|
||||||
char buf[30];
|
char buf[30];
|
||||||
_use_hwpalette = GetDriverParamInt(parm, "hw_palette", 2);
|
_use_hwpalette = GetDriverParamInt(parm, "hw_palette", 2);
|
||||||
|
@ -623,7 +623,7 @@ const char *VideoDriver_SDL::Start(const char * const *parm)
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
SetupKeyboard();
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The SDL video driver. */
|
/** The SDL video driver. */
|
||||||
class VideoDriver_SDL : public VideoDriver {
|
class VideoDriver_SDL : public VideoDriver {
|
||||||
public:
|
public:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char *_ini_videodriver;
|
extern std::string _ini_videodriver;
|
||||||
extern std::vector<Dimension> _resolutions;
|
extern std::vector<Dimension> _resolutions;
|
||||||
extern Dimension _cur_resolution;
|
extern Dimension _cur_resolution;
|
||||||
extern bool _rightclick_emulate;
|
extern bool _rightclick_emulate;
|
||||||
|
|
|
@ -1111,7 +1111,7 @@ static void FindResolutions()
|
||||||
|
|
||||||
static FVideoDriver_Win32 iFVideoDriver_Win32;
|
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));
|
memset(&_wnd, 0, sizeof(_wnd));
|
||||||
|
|
||||||
|
@ -1132,7 +1132,7 @@ const char *VideoDriver_Win32::Start(const char * const *parm)
|
||||||
|
|
||||||
MarkWholeScreenDirty();
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** The video driver for windows. */
|
/** The video driver for windows. */
|
||||||
class VideoDriver_Win32 : public VideoDriver {
|
class VideoDriver_Win32 : public VideoDriver {
|
||||||
public:
|
public:
|
||||||
const char *Start(const char * const *param) override;
|
const char *Start(const StringList ¶m) override;
|
||||||
|
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue