openttd updated to 1.5.0-beta2

--HG--
branch : openttd
This commit is contained in:
Pavel Stupnikov
2015-03-01 00:30:53 +03:00
parent 0abb47ce90
commit d201932121
682 changed files with 26103 additions and 16553 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: driver.cpp 26107 2013-11-25 14:26:46Z rubidium $ */
/* $Id: driver.cpp 26539 2014-04-28 21:09:19Z rubidium $ */
/*
* This file is part of OpenTTD.
@@ -16,17 +16,16 @@
#include "video/video_driver.hpp"
#include "string_func.h"
VideoDriver *_video_driver; ///< The currently active video driver.
#include "safeguards.h"
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 +85,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 +116,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 +176,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);
}
@@ -206,7 +224,7 @@ DriverFactoryBase::DriverFactoryBase(Driver::Type type, int priority, const char
strecpy(buf, GetDriverTypeName(type), lastof(buf));
strecpy(buf + 5, name, lastof(buf));
const char *longname = strdup(buf);
const char *longname = stredup(buf);
std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(longname, this));
assert(P.second);