1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-18 18:02:37 +01:00

(svn r26544) [1.4] -Backport from trunk:

- Fix: [Windows] Crash when the operating system performs the "paint" callback during window creation [FS#5994] (r26539, r26538)
- Fix: OpenBSD compilation [FS#5992] (r26523)
- Fix: prevent from ever reading huge (or negative) amounts of data in strgen (r26521)
- Fix: Severity rating of dedicated server messages during world generation (r26518)
This commit is contained in:
frosch
2014-04-29 18:41:19 +00:00
parent b720a16a1c
commit c57b316570
26 changed files with 114 additions and 80 deletions

View File

@@ -16,17 +16,14 @@
#include "video/video_driver.hpp"
#include "string_func.h"
VideoDriver *_video_driver; ///< The currently active video driver.
char *_ini_videodriver; ///< The video driver a stored in the configuration file.
int _num_resolutions; ///< The number of resolutions.
Dimension _resolutions[32]; ///< List of resolutions.
Dimension _cur_resolution; ///< The current resolution.
bool _rightclick_emulate; ///< Whether right clicking is emulated.
SoundDriver *_sound_driver; ///< The currently active sound driver.
char *_ini_sounddriver; ///< The sound driver a stored in the configuration file.
MusicDriver *_music_driver; ///< The currently active music driver.
char *_ini_musicdriver; ///< The music driver a stored in the configuration file.
char *_ini_blitter; ///< The blitter as stored in the configuration file.
@@ -86,9 +83,25 @@ int GetDriverParamInt(const char * const *parm, const char *name, int def)
* @param type the type of driver to select
* @post Sets the driver so GetCurrentDriver() returns it too.
*/
Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
void DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
{
if (GetDrivers().size() == 0) return NULL;
if (!DriverFactoryBase::SelectDriverImpl(name, type)) {
StrEmpty(name) ?
usererror("Failed to autoprobe %s driver", GetDriverTypeName(type)) :
usererror("Failed to select requested %s driver '%s'", GetDriverTypeName(type), name);
}
}
/**
* Find the requested driver and return its class.
* @param name the driver to select.
* @param type the type of driver to select
* @post Sets the driver so GetCurrentDriver() returns it too.
* @return True upon success, otherwise false.
*/
bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
{
if (GetDrivers().size() == 0) return false;
if (StrEmpty(name)) {
/* Probe for this driver, but do not fall back to dedicated/null! */
@@ -101,15 +114,18 @@ Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
if (d->type != type) continue;
if (d->priority != priority) continue;
Driver *oldd = *GetActiveDriver(type);
Driver *newd = d->CreateInstance();
*GetActiveDriver(type) = newd;
const char *err = newd->Start(NULL);
if (err == NULL) {
DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
delete *GetActiveDriver(type);
*GetActiveDriver(type) = newd;
return newd;
delete oldd;
return true;
}
*GetActiveDriver(type) = oldd;
DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err);
delete newd;
}
@@ -158,7 +174,7 @@ Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
DEBUG(driver, 1, "Successfully loaded %s driver '%s'", GetDriverTypeName(type), d->name);
delete *GetActiveDriver(type);
*GetActiveDriver(type) = newd;
return newd;
return true;
}
usererror("No such %s driver: %s\n", GetDriverTypeName(type), buffer);
}