1
0
Fork 0

(svn r25986) [1.3] -Backport from trunk:

- Fix: [GS] Language file scanner considered filenames starting with '.' as valid translations, resulting in languages with empty name, which causes trouble [FS#5750] (r25818)
- Fix: [GS] Handle savegames which contain GS translations for languages with empty name more gently [FS#5750] (r25817)
- Fix: [Script] ScriptTile::IsBuildableRectangle could report true for tiles outside of the map, if they happened to wrap around into a valid area [FS#5754] (r25815)
- Fix: Ensure the vehicle bar is high enough for the start/stop vehicle graphics [FS#5740] (r25805)
release/1.3
rubidium 2013-11-13 21:49:31 +00:00
parent f2cd6d20be
commit 33ab06a9da
6 changed files with 25 additions and 21 deletions

View File

@ -60,18 +60,11 @@ void NORETURN CDECL strgen_fatal(const char *s, ...)
/**
* Create a new container for language strings.
* @param language The language name.
* @param end If not NULL, terminate \a language at this position.
*/
LanguageStrings::LanguageStrings(const char *language)
LanguageStrings::LanguageStrings(const char *language, const char *end)
{
const char *p = strrchr(language, PATHSEPCHAR);
if (p == NULL) {
p = language;
} else {
p++;
}
const char *e = strchr(p, '.');
this->language = e == NULL ? strdup(p) : strndup(p, e - p);
this->language = end == NULL ? strdup(language) : strndup(language, end - language);
}
/** Free everything. */
@ -95,7 +88,17 @@ LanguageStrings *ReadRawLanguageStrings(const char *file)
return NULL;
}
ret = new LanguageStrings(file);
const char *langname = strrchr(file, PATHSEPCHAR);
if (langname == NULL) {
langname = file;
} else {
langname++;
}
/* Check for invalid empty filename */
if (*langname == '.' || *langname == 0) return NULL;
ret = new LanguageStrings(langname, strchr(langname, '.'));
char buffer[2048];
while (to_read != 0 && fgets(buffer, sizeof(buffer), fh) != NULL) {

View File

@ -26,7 +26,7 @@ struct LanguageStrings {
const char *language; ///< Name of the language (base filename).
StringList lines; ///< The lines of the file to pass into the parser/encoder.
LanguageStrings(const char *language);
LanguageStrings(const char *language, const char *end = NULL);
~LanguageStrings();
};

View File

@ -148,7 +148,7 @@ static void Load_GSTR()
_game_saveload_string = NULL;
SlObject(NULL, _game_language_header);
LanguageStrings *ls = new LanguageStrings(_game_saveload_string);
LanguageStrings *ls = new LanguageStrings(_game_saveload_string != NULL ? _game_saveload_string : "");
for (uint i = 0; i < _game_saveload_strings; i++) {
SlObject(NULL, _game_language_string);
*ls->lines.Append() = strdup(_game_saveload_string != NULL ? _game_saveload_string : "");

View File

@ -43,10 +43,11 @@
/* static */ bool ScriptTile::IsBuildableRectangle(TileIndex tile, uint width, uint height)
{
uint tx, ty;
/* Check whether we can extract valid X and Y */
if (!::IsValidTile(tile)) return false;
tx = ScriptMap::GetTileX(tile);
ty = ScriptMap::GetTileY(tile);
uint tx = ScriptMap::GetTileX(tile);
uint ty = ScriptMap::GetTileY(tile);
for (uint x = tx; x < width + tx; x++) {
for (uint y = ty; y < height + ty; y++) {

View File

@ -849,14 +849,10 @@ static void RunVehicleDayProc()
if (HasBit(callback, 0)) {
/* After a vehicle trigger, the graphics and properties of the vehicle could change. */
TriggerVehicle(v, VEHICLE_TRIGGER_CALLBACK_32); // Trigger vehicle trigger 10
v->MarkDirty();
v->First()->MarkDirty();
}
if (HasBit(callback, 1)) v->colourmap = PAL_NONE;
/* After a vehicle trigger, the graphics and properties of the vehicle could change.
* Note: MarkDirty also invalidates the palette, which is the meaning of bit 1. So, nothing special there. */
if (callback != 0) v->First()->MarkDirty();
if (callback & ~3) ErrorUnknownCallbackResult(v->GetGRFID(), CBID_VEHICLE_32DAY_CALLBACK, callback);
}
}

View File

@ -2394,6 +2394,10 @@ public:
{
const Vehicle *v = Vehicle::Get(this->window_number);
switch (widget) {
case WID_VV_START_STOP:
size->height = max(size->height, max(GetSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetSpriteSize(SPR_FLAG_VEH_RUNNING).height) + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
break;
case WID_VV_FORCE_PROCEED:
if (v->type != VEH_TRAIN) {
size->height = 0;