diff --git a/docs/HOWTO_compile_lang_files.txt b/docs/HOWTO_compile_lang_files.txt index ce5d6cd388..570381efa9 100644 --- a/docs/HOWTO_compile_lang_files.txt +++ b/docs/HOWTO_compile_lang_files.txt @@ -1,7 +1,7 @@ STRGEN USAGE ------------ 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 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 diff --git a/readme.txt b/readme.txt index 686cf99417..befefb41d6 100644 --- a/readme.txt +++ b/readme.txt @@ -381,10 +381,8 @@ The following libraries are used by OpenTTD for: See http://www.openttd.org/development for up-to-date information. The use of the online Translator service, located at -http://translator2.openttd.org/, is highly encouraged. For a username/password -combo you should contact the development team, either by mail, IRC or the -forums. The system is straightforward to use, and if you have any problems, -read the online help located there. +http://translator.openttd.org/, is highly encouraged. For getting an account +simply follow the guidelines in the FAQ of the translator website. If for some reason the website is down for a longer period of time, the information below might be of help. diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp index c4bde89b32..ec87499790 100644 --- a/src/ai/ai_scanner.cpp +++ b/src/ai/ai_scanner.cpp @@ -412,7 +412,7 @@ AIInfo *AIScanner::FindInfo(const char *nameParam, int versionParam) snprintf(ai_name_compare, sizeof(ai_name_compare), "%s", (*it).second->GetName()); 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(); info = (*it).second; } diff --git a/src/debug.h b/src/debug.h index b21cd6434d..f9aa0ecc4d 100644 --- a/src/debug.h +++ b/src/debug.h @@ -86,7 +86,7 @@ const char *GetDebugString(); #define TOC(str, count)\ __sum__ += ottd_rdtsc() - _xxx_;\ 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;\ __sum__ = 0;\ }\ diff --git a/src/driver.cpp b/src/driver.cpp index 5d5a86cd96..6a8ebc32b7 100644 --- a/src/driver.cpp +++ b/src/driver.cpp @@ -61,8 +61,8 @@ const Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type typ if (GetDrivers().size() == 0) return NULL; if (StrEmpty(name)) { - /* Probe for this driver */ - for (int priority = 10; priority >= 0; priority--) { + /* Probe for this driver, but do not fall back to dedicated/null! */ + for (int priority = 10; priority > 0; priority--) { Drivers::iterator it = GetDrivers().begin(); for (; it != GetDrivers().end(); ++it) { DriverFactoryBase *d = (*it).second; diff --git a/src/music/allegro_m.cpp b/src/music/allegro_m.cpp index 9400e7f495..1322ca54b3 100644 --- a/src/music/allegro_m.cpp +++ b/src/music/allegro_m.cpp @@ -18,15 +18,16 @@ extern int _allegro_instance_count; 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++; /* 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 */ if (midi_card == MIDI_NONE) { DEBUG(driver, 0, "allegro: no midi card found"); + return "No sound card found"; } return NULL; diff --git a/src/openttd.cpp b/src/openttd.cpp index 5aada53089..8d105648c6 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -539,10 +539,13 @@ int ttd_main(int argc, char *argv[]) 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; - /* The width and height must be at least 1 pixel, this - * way all internal drawing routines work correctly. */ - if (_cur_resolution.width <= 0) _cur_resolution.width = 1; - if (_cur_resolution.height <= 0) _cur_resolution.height = 1; + /* + * The width and height must be at least 1 pixel and width times + * height must still fit within a 32 bits integer, this way all + * 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 (dedicated_host) snprintf(_settings_client.network.server_bind_ip, sizeof(_settings_client.network.server_bind_ip), "%s", dedicated_host); diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp index e963bd03bf..6a26c5dc0e 100644 --- a/src/saveload/ai_sl.cpp +++ b/src/saveload/ai_sl.cpp @@ -70,12 +70,20 @@ static void Load_AIPL() } else { config->ChangeAI(_ai_saveload_name, _ai_saveload_version); if (!config->HasAI()) { - 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, "A random other AI will be loaded in its place."); + /* 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 (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, "A random other AI will be loaded in its place."); + } else { + 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."); + } } else { - 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, "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 * writer of the saveload data in the first place */ diff --git a/src/sound/allegro_s.cpp b/src/sound/allegro_s.cpp index 977f33bc87..069e473e5f 100644 --- a/src/sound/allegro_s.cpp +++ b/src/sound/allegro_s.cpp @@ -45,16 +45,16 @@ extern int _allegro_instance_count; 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++; /* 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 */ if (digi_card == DIGI_NONE) { 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); diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index e0509aa520..b376d1aec4 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -404,7 +404,7 @@ int _allegro_instance_count = 0; 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++; install_timer(); @@ -425,7 +425,9 @@ const char *VideoDriver_Allegro::Start(const char * const *parm) #endif GetVideoModes(); - CreateMainSurface(_cur_resolution.width, _cur_resolution.height); + if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) { + return "Failed to set up Allegro video"; + } MarkWholeScreenDirty(); set_close_button_callback(HandleExitGameRequest); diff --git a/src/video/null_v.h b/src/video/null_v.h index c45a5a46c8..80d9d58d92 100644 --- a/src/video/null_v.h +++ b/src/video/null_v.h @@ -27,7 +27,7 @@ public: class FVideoDriver_Null: public VideoDriverFactory { public: - static const int priority = 1; + static const int priority = 0; /* virtual */ const char *GetName() { return "null"; } /* virtual */ const char *GetDescription() { return "Null Video Driver"; } /* virtual */ Driver *CreateInstance() { return new VideoDriver_Null(); } diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index e9068bd7e2..cd7b55e8cf 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -426,11 +426,14 @@ const char *VideoDriver_SDL::Start(const char * const *parm) const char *s = SdlOpen(SDL_INIT_VIDEO); 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); DEBUG(driver, 1, "SDL: using driver '%s'", buf); - GetVideoModes(); - CreateMainSurface(_cur_resolution.width, _cur_resolution.height); MarkWholeScreenDirty(); SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); diff --git a/src/yapf/yapf_node_rail.hpp b/src/yapf/yapf_node_rail.hpp index 2830c64e63..3385d3acdf 100644 --- a/src/yapf/yapf_node_rail.hpp +++ b/src/yapf/yapf_node_rail.hpp @@ -114,7 +114,7 @@ inline CStrA ValueStr(EndSegmentReasonBits bits) { static const char *end_segment_reason_names[] = { "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" };