1
0
Fork 0

(svn r16704) [0.7] -Backport from trunk:

- Fix: When SDL/Allegro fail to initialise, fall back on another video driver but not to the null driver (r16702, r16700, r16699)
- Fix: Limit the screen's resolution to 65535x65535 so the dirty pixels stay within bounds of a 32 bits integer [FS#3001] (r16701)
- Fix: Missing debug string for ESRB_SAFE_TILE in YAPF debugging helper [FS#3002] (r16690)
- Fix: When there is no AI version that can load data from the savegame, load the latest version of the same AI instead of a random AI (r16651, r16650, r16649)
release/0.7
rubidium 2009-06-30 20:11:36 +00:00
parent 0ffca06944
commit b49c6e0cbd
13 changed files with 44 additions and 29 deletions

View File

@ -1,7 +1,7 @@
STRGEN USAGE STRGEN USAGE
------------ ------------
This guide is only interesting for people who want to alter something This guide is only interesting for people who want to alter something
themselves without access to WT2 (translator2.openttd.org). Please note that themselves without access to translator.openttd.org. Please note that
your compiled language file will only be compatible with the OpenTTD version your compiled language file will only be compatible with the OpenTTD version
you have downloaded english.txt, the master language file, for. While this is you have downloaded english.txt, the master language file, for. While this is
not always true, namely when changes in the code have not touched language not always true, namely when changes in the code have not touched language

View File

@ -381,10 +381,8 @@ The following libraries are used by OpenTTD for:
See http://www.openttd.org/development for up-to-date information. See http://www.openttd.org/development for up-to-date information.
The use of the online Translator service, located at The use of the online Translator service, located at
http://translator2.openttd.org/, is highly encouraged. For a username/password http://translator.openttd.org/, is highly encouraged. For getting an account
combo you should contact the development team, either by mail, IRC or the simply follow the guidelines in the FAQ of the translator website.
forums. The system is straightforward to use, and if you have any problems,
read the online help located there.
If for some reason the website is down for a longer period of time, the If for some reason the website is down for a longer period of time, the
information below might be of help. information below might be of help.

View File

@ -412,7 +412,7 @@ AIInfo *AIScanner::FindInfo(const char *nameParam, int versionParam)
snprintf(ai_name_compare, sizeof(ai_name_compare), "%s", (*it).second->GetName()); snprintf(ai_name_compare, sizeof(ai_name_compare), "%s", (*it).second->GetName());
strtolower(ai_name_compare); strtolower(ai_name_compare);
if (strcasecmp(ai_name, ai_name_compare) == 0 && (*it).second->CanLoadFromVersion(versionParam)) { if (strcasecmp(ai_name, ai_name_compare) == 0 && (*it).second->CanLoadFromVersion(versionParam) && (version == -1 || (*it).second->GetVersion() > version)) {
version = (*it).second->GetVersion(); version = (*it).second->GetVersion();
info = (*it).second; info = (*it).second;
} }

View File

@ -86,7 +86,7 @@ const char *GetDebugString();
#define TOC(str, count)\ #define TOC(str, count)\
__sum__ += ottd_rdtsc() - _xxx_;\ __sum__ += ottd_rdtsc() - _xxx_;\
if (++__i__ == count) {\ if (++__i__ == count) {\
DEBUG(misc, 0, "[%s] %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\ DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\
__i__ = 0;\ __i__ = 0;\
__sum__ = 0;\ __sum__ = 0;\
}\ }\

View File

@ -61,8 +61,8 @@ const Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type typ
if (GetDrivers().size() == 0) return NULL; if (GetDrivers().size() == 0) return NULL;
if (StrEmpty(name)) { if (StrEmpty(name)) {
/* Probe for this driver */ /* 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();
for (; it != GetDrivers().end(); ++it) { for (; it != GetDrivers().end(); ++it) {
DriverFactoryBase *d = (*it).second; DriverFactoryBase *d = (*it).second;

View File

@ -18,15 +18,16 @@ extern int _allegro_instance_count;
const char *MusicDriver_Allegro::Start(const char * const *param) const char *MusicDriver_Allegro::Start(const char * const *param)
{ {
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return NULL; if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return "Failed to set up Allegro";
_allegro_instance_count++; _allegro_instance_count++;
/* Initialise the sound */ /* Initialise the sound */
if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) return NULL; if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) return "Failed to set up Allegro sound";
/* Okay, there's no soundcard */ /* Okay, there's no soundcard */
if (midi_card == MIDI_NONE) { if (midi_card == MIDI_NONE) {
DEBUG(driver, 0, "allegro: no midi card found"); DEBUG(driver, 0, "allegro: no midi card found");
return "No sound card found";
} }
return NULL; return NULL;

View File

@ -539,10 +539,13 @@ int ttd_main(int argc, char *argv[])
if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear; 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; if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
/* The width and height must be at least 1 pixel, this /*
* way all internal drawing routines work correctly. */ * The width and height must be at least 1 pixel and width times
if (_cur_resolution.width <= 0) _cur_resolution.width = 1; * height must still fit within a 32 bits integer, this way all
if (_cur_resolution.height <= 0) _cur_resolution.height = 1; * internal drawing routines work correctly.
*/
_cur_resolution.width = ClampU(_cur_resolution.width, 1, UINT16_MAX);
_cur_resolution.height = ClampU(_cur_resolution.height, 1, UINT16_MAX);
#if defined(ENABLE_NETWORK) #if defined(ENABLE_NETWORK)
if (dedicated_host) snprintf(_settings_client.network.server_bind_ip, sizeof(_settings_client.network.server_bind_ip), "%s", dedicated_host); if (dedicated_host) snprintf(_settings_client.network.server_bind_ip, sizeof(_settings_client.network.server_bind_ip), "%s", dedicated_host);

View File

@ -69,6 +69,10 @@ static void Load_AIPL()
config->ChangeAI(NULL); config->ChangeAI(NULL);
} else { } else {
config->ChangeAI(_ai_saveload_name, _ai_saveload_version); config->ChangeAI(_ai_saveload_name, _ai_saveload_version);
if (!config->HasAI()) {
/* No version of the AI available that can load the data. Try to load the
* latest version of the AI instead. */
config->ChangeAI(_ai_saveload_name, -1);
if (!config->HasAI()) { if (!config->HasAI()) {
if (strcmp(_ai_saveload_name, "%_dummy") != 0) { if (strcmp(_ai_saveload_name, "%_dummy") != 0) {
DEBUG(ai, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version); DEBUG(ai, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version);
@ -77,6 +81,10 @@ static void Load_AIPL()
DEBUG(ai, 0, "The savegame had no AIs available at the time of saving."); DEBUG(ai, 0, "The savegame had no AIs available at the time of saving.");
DEBUG(ai, 0, "A random available AI will be loaded now."); DEBUG(ai, 0, "A random available AI will be loaded now.");
} }
} else {
DEBUG(ai, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version);
DEBUG(ai, 0, "The latest version of that AI has been loaded instead, but it'll not get the savegame data as it's incompatible.");
}
/* Make sure the AI doesn't get the saveload data, as he was not the /* Make sure the AI doesn't get the saveload data, as he was not the
* writer of the saveload data in the first place */ * writer of the saveload data in the first place */
_ai_saveload_version = -1; _ai_saveload_version = -1;

View File

@ -45,16 +45,16 @@ extern int _allegro_instance_count;
const char *SoundDriver_Allegro::Start(const char * const *parm) const char *SoundDriver_Allegro::Start(const char * const *parm)
{ {
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return NULL; if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return "Failed to set up Allegro";
_allegro_instance_count++; _allegro_instance_count++;
/* Initialise the sound */ /* Initialise the sound */
if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) return NULL; if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) return "Failed to set up Allegro sound";
/* Okay, there's no soundcard */ /* Okay, there's no soundcard */
if (digi_card == DIGI_NONE) { if (digi_card == DIGI_NONE) {
DEBUG(driver, 0, "allegro: no sound card found"); DEBUG(driver, 0, "allegro: no sound card found");
return NULL; return "No sound card found";
} }
_stream = play_audio_stream(BUFFER_SIZE, 16, true, 11025, 255, 128); _stream = play_audio_stream(BUFFER_SIZE, 16, true, 11025, 255, 128);

View File

@ -404,7 +404,7 @@ int _allegro_instance_count = 0;
const char *VideoDriver_Allegro::Start(const char * const *parm) const char *VideoDriver_Allegro::Start(const char * const *parm)
{ {
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return NULL; if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return "Failed to set up Allegro";
_allegro_instance_count++; _allegro_instance_count++;
install_timer(); install_timer();
@ -425,7 +425,9 @@ const char *VideoDriver_Allegro::Start(const char * const *parm)
#endif #endif
GetVideoModes(); GetVideoModes();
CreateMainSurface(_cur_resolution.width, _cur_resolution.height); if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
return "Failed to set up Allegro video";
}
MarkWholeScreenDirty(); MarkWholeScreenDirty();
set_close_button_callback(HandleExitGameRequest); set_close_button_callback(HandleExitGameRequest);

View File

@ -27,7 +27,7 @@ public:
class FVideoDriver_Null: public VideoDriverFactory<FVideoDriver_Null> { class FVideoDriver_Null: public VideoDriverFactory<FVideoDriver_Null> {
public: public:
static const int priority = 1; static const int priority = 0;
/* virtual */ const char *GetName() { return "null"; } /* virtual */ const char *GetName() { return "null"; }
/* virtual */ const char *GetDescription() { return "Null Video Driver"; } /* virtual */ const char *GetDescription() { return "Null Video Driver"; }
/* virtual */ Driver *CreateInstance() { return new VideoDriver_Null(); } /* virtual */ Driver *CreateInstance() { return new VideoDriver_Null(); }

View File

@ -426,11 +426,14 @@ const char *VideoDriver_SDL::Start(const char * const *parm)
const char *s = SdlOpen(SDL_INIT_VIDEO); const char *s = SdlOpen(SDL_INIT_VIDEO);
if (s != NULL) return s; if (s != NULL) return s;
GetVideoModes();
if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
return SDL_CALL SDL_GetError();
}
SDL_CALL SDL_VideoDriverName(buf, 30); SDL_CALL SDL_VideoDriverName(buf, 30);
DEBUG(driver, 1, "SDL: using driver '%s'", buf); DEBUG(driver, 1, "SDL: using driver '%s'", buf);
GetVideoModes();
CreateMainSurface(_cur_resolution.width, _cur_resolution.height);
MarkWholeScreenDirty(); MarkWholeScreenDirty();
SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

View File

@ -114,7 +114,7 @@ inline CStrA ValueStr(EndSegmentReasonBits bits)
{ {
static const char *end_segment_reason_names[] = { static const char *end_segment_reason_names[] = {
"DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS", "DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS",
"DEPOT", "WAYPOINT", "STATION", "DEPOT", "WAYPOINT", "STATION", "SAFE_TILE",
"PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED" "PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED"
}; };