mirror of https://github.com/OpenTTD/OpenTTD
(svn r25559) [1.3] -Backport from trunk:
- Fix: Possible reading of uninitialised memory due to undefined execution order (r25551) - Fix: [Windows] Race condition between two drawing threads could crash OpenTTD [FS#5571] (r25550) - Fix: ICU returns the width of the visual run as if the trailing space was added (in case a newline was added). This caused the width to be more than the requested width, but it would still be drawn correctly [FS#5626] (r25547) - Fix: Two small memory leaks (r25546) - Fix: [GS] The checks and validations for setting the extra text in the town window became too stringent [FS#5625] (r25544)release/1.3
parent
441364ff91
commit
526fb6fa21
|
@ -302,11 +302,12 @@ static void SetColourRemap(TextColour colour)
|
||||||
* case a right-to-left language is chosen this is inverted so it
|
* case a right-to-left language is chosen this is inverted so it
|
||||||
* will be drawn in the right direction.
|
* will be drawn in the right direction.
|
||||||
* @param underline Whether to underline what has been drawn or not.
|
* @param underline Whether to underline what has been drawn or not.
|
||||||
|
* @param truncation Whether to perform string truncation or not.
|
||||||
*
|
*
|
||||||
* @return In case of left or center alignment the right most pixel we have drawn to.
|
* @return In case of left or center alignment the right most pixel we have drawn to.
|
||||||
* In case of right alignment the left most pixel we have drawn to.
|
* In case of right alignment the left most pixel we have drawn to.
|
||||||
*/
|
*/
|
||||||
static int DrawLayoutLine(ParagraphLayout::Line *line, int y, int left, int right, StringAlignment align, bool underline)
|
static int DrawLayoutLine(ParagraphLayout::Line *line, int y, int left, int right, StringAlignment align, bool underline, bool truncation)
|
||||||
{
|
{
|
||||||
if (line->countRuns() == 0) return 0;
|
if (line->countRuns() == 0) return 0;
|
||||||
|
|
||||||
|
@ -331,7 +332,7 @@ static int DrawLayoutLine(ParagraphLayout::Line *line, int y, int left, int righ
|
||||||
int min_x = left; // The minimum x position to draw normal glyphs on.
|
int min_x = left; // The minimum x position to draw normal glyphs on.
|
||||||
int max_x = right; // The maximum x position to draw normal glyphs on.
|
int max_x = right; // The maximum x position to draw normal glyphs on.
|
||||||
|
|
||||||
bool truncation = max_w < w; // Whether we need to do truncation.
|
truncation &= max_w < w; // Whether we need to do truncation.
|
||||||
int dot_width = 0; // Cache for the width of the dot.
|
int dot_width = 0; // Cache for the width of the dot.
|
||||||
const Sprite *dot_sprite = NULL; // Cache for the sprite of the dot.
|
const Sprite *dot_sprite = NULL; // Cache for the sprite of the dot.
|
||||||
|
|
||||||
|
@ -458,7 +459,7 @@ int DrawString(int left, int right, int top, const char *str, TextColour colour,
|
||||||
Layouter layout(str, INT32_MAX, colour, fontsize);
|
Layouter layout(str, INT32_MAX, colour, fontsize);
|
||||||
if (layout.Length() == 0) return 0;
|
if (layout.Length() == 0) return 0;
|
||||||
|
|
||||||
return DrawLayoutLine(*layout.Begin(), top, left, right, align, underline);
|
return DrawLayoutLine(*layout.Begin(), top, left, right, align, underline, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -600,7 +601,7 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, const char *st
|
||||||
last_line = y + line_height;
|
last_line = y + line_height;
|
||||||
if (first_line > y) first_line = y;
|
if (first_line > y) first_line = y;
|
||||||
|
|
||||||
DrawLayoutLine(line, y, left, right, align, underline);
|
DrawLayoutLine(line, y, left, right, align, underline, false);
|
||||||
}
|
}
|
||||||
y += line_height;
|
y += line_height;
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,8 @@ ParagraphLayout::Line *ParagraphLayout::nextLine(int max_width)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->buffer == next_run) {
|
if (this->buffer == next_run) {
|
||||||
*l->Append() = new VisualRun(iter->second, begin, this->buffer - begin, l->getWidth());
|
int w = l->getWidth();
|
||||||
|
*l->Append() = new VisualRun(iter->second, begin, this->buffer - begin, w);
|
||||||
iter++;
|
iter++;
|
||||||
assert(iter != this->runs.End());
|
assert(iter != this->runs.End());
|
||||||
|
|
||||||
|
@ -365,7 +366,8 @@ ParagraphLayout::Line *ParagraphLayout::nextLine(int max_width)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->Length() == 0 || last_char - begin != 0) {
|
if (l->Length() == 0 || last_char - begin != 0) {
|
||||||
*l->Append() = new VisualRun(iter->second, begin, last_char - begin, l->getWidth());
|
int w = l->getWidth();
|
||||||
|
*l->Append() = new VisualRun(iter->second, begin, last_char - begin, w);
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,9 @@
|
||||||
CCountedPtr<Text> counter(text);
|
CCountedPtr<Text> counter(text);
|
||||||
|
|
||||||
EnforcePrecondition(false, text != NULL);
|
EnforcePrecondition(false, text != NULL);
|
||||||
const char *encoded_text = text->GetDecodedText();
|
const char *encoded_text = text->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(false, encoded_text);
|
EnforcePreconditionEncodedText(false, encoded_text);
|
||||||
EnforcePrecondition(false, IsValidTown(town_id));
|
EnforcePrecondition(false, IsValidTown(town_id));
|
||||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(encoded_text) < MAX_LENGTH_TOWN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
|
||||||
|
|
||||||
return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, encoded_text);
|
return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, encoded_text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ ScriptScanner::~ScriptScanner()
|
||||||
this->Reset();
|
this->Reset();
|
||||||
|
|
||||||
free(this->main_script);
|
free(this->main_script);
|
||||||
|
free(this->tar_file);
|
||||||
delete this->engine;
|
delete this->engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,7 @@ static void ClientSizeChanged(int w, int h)
|
||||||
{
|
{
|
||||||
/* allocate new dib section of the new size */
|
/* allocate new dib section of the new size */
|
||||||
if (AllocateDibSection(w, h)) {
|
if (AllocateDibSection(w, h)) {
|
||||||
|
if (_draw_mutex != NULL) _draw_mutex->BeginCritical();
|
||||||
/* mark all palette colours dirty */
|
/* mark all palette colours dirty */
|
||||||
_cur_palette.first_dirty = 0;
|
_cur_palette.first_dirty = 0;
|
||||||
_cur_palette.count_dirty = 256;
|
_cur_palette.count_dirty = 256;
|
||||||
|
@ -190,6 +191,8 @@ static void ClientSizeChanged(int w, int h)
|
||||||
_screen.dst_ptr = _wnd.buffer_bits;
|
_screen.dst_ptr = _wnd.buffer_bits;
|
||||||
UpdateWindows();
|
UpdateWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_draw_mutex != NULL) _draw_mutex->EndCritical();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue