summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-09-13 12:28:53 +0000
committertruelight <truelight@openttd.org>2007-09-13 12:28:53 +0000
commitf1336fba6821591cd2a9b40d8fa4b2f6c6e2423c (patch)
tree7a9902f87091957529265ccda02342bdc7d7ae6d /src
parent1e4f8d7a236e3cdc0871fa0e102a5baa660c7060 (diff)
downloadopenttd-f1336fba6821591cd2a9b40d8fa4b2f6c6e2423c.tar.xz
(svn r11092) -Add: allow 'blitter=<value>' in openttd.cfg to set the blitter (so you don't have to keep on doing 'openttd -b 32bpp-optimized'..)
Diffstat (limited to 'src')
-rw-r--r--src/blitter/factory.hpp6
-rw-r--r--src/openttd.cpp12
-rw-r--r--src/settings.cpp1
-rw-r--r--src/variables.h2
4 files changed, 13 insertions, 8 deletions
diff --git a/src/blitter/factory.hpp b/src/blitter/factory.hpp
index beb35cba5..3e7fc954a 100644
--- a/src/blitter/factory.hpp
+++ b/src/blitter/factory.hpp
@@ -4,6 +4,7 @@
#define BLITTER_FACTORY_HPP
#include "base.hpp"
+#include "../string.h"
#include <string>
#include <map>
@@ -61,12 +62,15 @@ public:
*/
static Blitter *SelectBlitter(const char *name)
{
+ const char *default_blitter = "8bpp-optimized";
+
if (GetBlitters().size() == 0) return NULL;
+ const char *bname = (StrEmpty(name)) ? default_blitter : name;
Blitters::iterator it = GetBlitters().begin();
for (; it != GetBlitters().end(); it++) {
BlitterFactoryBase *b = (*it).second;
- if (strcasecmp(name, b->name) == 0) {
+ if (strcasecmp(bname, b->name) == 0) {
Blitter *newb = b->CreateInstance();
delete *GetActiveBlitter();
*GetActiveBlitter() = newb;
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 07aaefd3a..bed5dbdb0 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -89,8 +89,6 @@ extern Player* DoStartupNewPlayer(bool is_ai);
extern void ShowOSErrorBox(const char *buf);
extern void SetDefaultRailGui();
-const char *_default_blitter = "8bpp-optimized";
-
/* TODO: usrerror() for errors which are not of an internal nature but
* caused by the user, i.e. missing files or fatal configuration errors.
* Post-0.4.0 since Celestar doesn't want this in SVN before. --pasky */
@@ -474,7 +472,7 @@ int ttd_main(int argc, char *argv[])
if (!StrEmpty(musicdriver)) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
- if (StrEmpty(blitter)) ttd_strlcpy(blitter, _default_blitter, sizeof(blitter));
+ if (!StrEmpty(blitter)) ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
@@ -519,9 +517,11 @@ int ttd_main(int argc, char *argv[])
/* Initialize game palette */
GfxInitPalettes();
- DEBUG(misc, 1, "Loading blitter '%s'...", blitter);
- if (BlitterFactoryBase::SelectBlitter(blitter) == NULL)
- error("Failed to select requested blitter '%s'; does it exist?", blitter);
+ DEBUG(misc, 1, "Loading blitter...");
+ if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL)
+ StrEmpty(_ini_blitter) ?
+ error("Failed to autoprobe blitter") :
+ error("Failed to select requested blitter '%s'; does it exist?", _ini_blitter);
DEBUG(driver, 1, "Loading drivers...");
diff --git a/src/settings.cpp b/src/settings.cpp
index 3aaa7941b..9178650fc 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1245,6 +1245,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
SDTG_STR("videodriver", SLE_STRB,C|S,0, _ini_videodriver, NULL, STR_NULL, NULL),
SDTG_STR("musicdriver", SLE_STRB,C|S,0, _ini_musicdriver, NULL, STR_NULL, NULL),
SDTG_STR("sounddriver", SLE_STRB,C|S,0, _ini_sounddriver, NULL, STR_NULL, NULL),
+ SDTG_STR("blitter", SLE_STRB,C|S,0, _ini_blitter, NULL, STR_NULL, NULL),
SDTG_STR("language", SLE_STRB, S, 0, _dynlang.curr_file, NULL, STR_NULL, NULL),
SDTG_LIST("resolution", SLE_UINT16, S, 0, _cur_resolution, "640,480", STR_NULL, NULL),
SDTG_STR("screenshot_format",SLE_STRB, S, 0, _screenshot_format_name,NULL, STR_NULL, NULL),
diff --git a/src/variables.h b/src/variables.h
index 58510ed98..f367e7baf 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -315,7 +315,7 @@ VARDEF SmallFiosItem _file_to_saveload;
VARDEF Vehicle *_place_clicked_vehicle;
-VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32];
+VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32], _ini_blitter[32];
VARDEF int _num_resolutions;
VARDEF uint16 _resolutions[32][2];