summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-01-08 11:06:07 +0000
committerpeter1138 <peter1138@openttd.org>2009-01-08 11:06:07 +0000
commit6b6fd360505d4ec65a1a013a0dc4dbd4b121ddbf (patch)
tree9e096ed24353259d9aea2b2145a2d8830d9ec7f2
parentc71862174a60e0719751afa9ca8f2ebcaa774f39 (diff)
downloadopenttd-6b6fd360505d4ec65a1a013a0dc4dbd4b121ddbf.tar.xz
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
-rw-r--r--src/blitter/factory.hpp2
-rw-r--r--src/driver.cpp10
-rw-r--r--src/gfxinit.cpp2
-rw-r--r--src/gfxinit.h2
-rw-r--r--src/music/music_driver.hpp2
-rw-r--r--src/openttd.cpp44
-rw-r--r--src/settings.cpp10
-rw-r--r--src/sound/sound_driver.hpp2
-rw-r--r--src/video/video_driver.hpp2
9 files changed, 47 insertions, 29 deletions
diff --git a/src/blitter/factory.hpp b/src/blitter/factory.hpp
index 30b680506..7ac8dbde5 100644
--- a/src/blitter/factory.hpp
+++ b/src/blitter/factory.hpp
@@ -155,6 +155,6 @@ public:
const char *GetName();
};
-extern char _ini_blitter[32];
+extern char *_ini_blitter;
#endif /* BLITTER_FACTORY_HPP */
diff --git a/src/driver.cpp b/src/driver.cpp
index dc8ffb1af..99462de6c 100644
--- a/src/driver.cpp
+++ b/src/driver.cpp
@@ -12,18 +12,18 @@
#include "video/video_driver.hpp"
VideoDriver *_video_driver;
-char _ini_videodriver[32];
+char *_ini_videodriver;
int _num_resolutions;
Dimension _resolutions[32];
Dimension _cur_resolution;
SoundDriver *_sound_driver;
-char _ini_sounddriver[32];
+char *_ini_sounddriver;
MusicDriver *_music_driver;
-char _ini_musicdriver[32];
+char *_ini_musicdriver;
-char _ini_blitter[32];
+char *_ini_blitter;
static const char* GetDriverParam(const char* const* parm, const char* name)
{
@@ -63,7 +63,7 @@ const Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type typ
{
if (GetDrivers().size() == 0) return NULL;
- if (*name == '\0') {
+ if (StrEmpty(name)) {
/* Probe for this driver */
for (int priority = 10; priority >= 0; priority--) {
Drivers::iterator it = GetDrivers().begin();
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 8d25c3d24..ea30d13ca 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -34,7 +34,7 @@ const byte *_palette_remap = NULL;
/** Palette map to go from the _use_palette to the !_use_palette */
const byte *_palette_reverse_remap = NULL;
-char _ini_graphics_set[32];
+char *_ini_graphics_set;
/** Structure holding filename and MD5 information about a single file */
struct MD5File {
diff --git a/src/gfxinit.h b/src/gfxinit.h
index 2caa5f54c..deaa6c32c 100644
--- a/src/gfxinit.h
+++ b/src/gfxinit.h
@@ -15,6 +15,6 @@ void FindGraphicsSets();
bool SetGraphicsSet(const char *name);
char *GetGraphicsSetsList(char *p, const char *last);
-extern char _ini_graphics_set[32];
+extern char *_ini_graphics_set;
#endif /* GFXINIT_H */
diff --git a/src/music/music_driver.hpp b/src/music/music_driver.hpp
index c4cc6bc3f..6181acdbb 100644
--- a/src/music/music_driver.hpp
+++ b/src/music/music_driver.hpp
@@ -33,6 +33,6 @@ public:
};
extern MusicDriver *_music_driver;
-extern char _ini_musicdriver[32];
+extern char *_ini_musicdriver;
#endif /* MUSIC_MUSIC_DRIVER_HPP */
diff --git a/src/openttd.cpp b/src/openttd.cpp
index fd478955d..d4ee57152 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -391,7 +391,11 @@ int ttd_main(int argc, char *argv[])
{
int i;
const char *optformat;
- char musicdriver[32], sounddriver[32], videodriver[32], blitter[32], graphics_set[32];
+ char *musicdriver = NULL;
+ char *sounddriver = NULL;
+ char *videodriver = NULL;
+ char *blitter = NULL;
+ char *graphics_set = NULL;
Dimension resolution = {0, 0};
Year startyear = INVALID_YEAR;
uint generation_seed = GENERATE_NEW_SEED;
@@ -405,8 +409,6 @@ int ttd_main(int argc, char *argv[])
uint16 dedicated_port = 0;
#endif /* ENABLE_NETWORK */
- musicdriver[0] = sounddriver[0] = videodriver[0] = blitter[0] = graphics_set[0] = '\0';
-
_game_mode = GM_MENU;
_switch_mode = SM_MENU;
_switch_mode_errorstr = INVALID_STRING_ID;
@@ -427,11 +429,11 @@ int ttd_main(int argc, char *argv[])
while ((i = MyGetOpt(&mgo)) != -1) {
switch (i) {
- case 'I': strecpy(graphics_set, mgo.opt, lastof(graphics_set)); break;
- case 'm': strecpy(musicdriver, mgo.opt, lastof(musicdriver)); break;
- case 's': strecpy(sounddriver, mgo.opt, lastof(sounddriver)); break;
- case 'v': strecpy(videodriver, mgo.opt, lastof(videodriver)); break;
- case 'b': strecpy(blitter, mgo.opt, lastof(blitter)); break;
+ case 'I': free(graphics_set); graphics_set = strdup(mgo.opt); break;
+ case 'm': free(musicdriver); musicdriver = strdup(mgo.opt); break;
+ case 's': free(sounddriver); sounddriver = strdup(mgo.opt); break;
+ case 'v': free(videodriver); videodriver = strdup(mgo.opt); break;
+ case 'b': free(blitter); blitter = strdup(mgo.opt); break;
#if defined(ENABLE_NETWORK)
case 'D':
strcpy(musicdriver, "null");
@@ -531,11 +533,27 @@ int ttd_main(int argc, char *argv[])
/* override config? */
- if (!StrEmpty(graphics_set)) strecpy(_ini_graphics_set, graphics_set, lastof(_ini_graphics_set));
- if (!StrEmpty(musicdriver)) strecpy(_ini_musicdriver, musicdriver, lastof(_ini_musicdriver));
- if (!StrEmpty(sounddriver)) strecpy(_ini_sounddriver, sounddriver, lastof(_ini_sounddriver));
- if (!StrEmpty(videodriver)) strecpy(_ini_videodriver, videodriver, lastof(_ini_videodriver));
- if (!StrEmpty(blitter)) strecpy(_ini_blitter, blitter, lastof(_ini_blitter));
+ if (!StrEmpty(graphics_set)) {
+ free(_ini_graphics_set);
+ _ini_graphics_set = graphics_set;
+ }
+ if (!StrEmpty(musicdriver)) {
+ free(_ini_musicdriver);
+ _ini_musicdriver = musicdriver;
+ }
+ if (!StrEmpty(sounddriver)) {
+ free(_ini_sounddriver);
+ _ini_sounddriver = sounddriver;
+ }
+ if (!StrEmpty(videodriver)) {
+ free(_ini_videodriver);
+ _ini_videodriver = videodriver;
+ }
+ if (!StrEmpty(blitter)) {
+ free(_ini_blitter);
+ _ini_blitter = blitter;
+ }
+
if (resolution.width != 0) { _cur_resolution = resolution; }
if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
diff --git a/src/settings.cpp b/src/settings.cpp
index 731efa51c..c26ad66ae 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1161,11 +1161,11 @@ static const SettingDescGlobVarList _misc_settings[] = {
SDTG_MMANY("display_opt", SLE_UINT8, S, 0, _display_opt, (1 << DO_SHOW_TOWN_NAMES | 1 << DO_SHOW_STATION_NAMES | 1 << DO_SHOW_SIGNS | 1 << DO_FULL_ANIMATION | 1 << DO_FULL_DETAIL | 1 << DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION||FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
SDTG_BOOL("news_ticker_sound", S, 0, _news_ticker_sound, true, STR_NULL, NULL),
SDTG_BOOL("fullscreen", S, 0, _fullscreen, false, STR_NULL, NULL),
- SDTG_STR("graphicsset", SLE_STRB,C|S,0, _ini_graphics_set, NULL, STR_NULL, NULL),
- 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("graphicsset", SLE_STRQ,C|S,0, _ini_graphics_set, NULL, STR_NULL, NULL),
+ SDTG_STR("videodriver", SLE_STRQ,C|S,0, _ini_videodriver, NULL, STR_NULL, NULL),
+ SDTG_STR("musicdriver", SLE_STRQ,C|S,0, _ini_musicdriver, NULL, STR_NULL, NULL),
+ SDTG_STR("sounddriver", SLE_STRQ,C|S,0, _ini_sounddriver, NULL, STR_NULL, NULL),
+ SDTG_STR("blitter", SLE_STRQ,C|S,0, _ini_blitter, NULL, STR_NULL, NULL),
SDTG_STR("language", SLE_STRB, S, 0, _dynlang.curr_file, NULL, STR_NULL, NULL),
SDTG_CONDLIST("resolution", SLE_INT, 2, S, 0, _cur_resolution, "640,480", STR_NULL, NULL, 0, SL_MAX_VERSION), // workaround for implicit lengthof() in SDTG_LIST
SDTG_STR("screenshot_format",SLE_STRB, S, 0, _screenshot_format_name,NULL, STR_NULL, NULL),
diff --git a/src/sound/sound_driver.hpp b/src/sound/sound_driver.hpp
index 5756db309..c1b8c8a77 100644
--- a/src/sound/sound_driver.hpp
+++ b/src/sound/sound_driver.hpp
@@ -28,6 +28,6 @@ public:
};
extern SoundDriver *_sound_driver;
-extern char _ini_sounddriver[32];
+extern char *_ini_sounddriver;
#endif /* SOUND_SOUND_DRIVER_HPP */
diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp
index d19e8b1c7..ca5a3a97d 100644
--- a/src/video/video_driver.hpp
+++ b/src/video/video_driver.hpp
@@ -34,7 +34,7 @@ public:
};
extern VideoDriver *_video_driver;
-extern char _ini_videodriver[32];
+extern char *_ini_videodriver;
extern int _num_resolutions;
extern Dimension _resolutions[32];
extern Dimension _cur_resolution;