Under normal circumstances the server's ID is 32 characters excluding '\0', however this can be changed at the server. This ID is sent to the server for company name hashing. The client reads it into a statically allocated buffer of 33 bytes, but fills only the bytes it received from the server. However, the hash assumes all 33 bytes are set, thus potentially reading uninitialized data, or a part of the server ID of a previous game in the hashing routine.
It is still reading from memory assigned to the server ID, so nothing bad happens, except that company passwords might not work correctly.
(cherry picked from commit 56aa6d0edd)
If a viewport sign straddles the top of a viewport, a crash will occur if the viewport height is zero. This is resolved by simply not attempting to draw the viewport in this situation, consistent with other widgets.
(cherry picked from commit 256dbee255)
Previously noted by a comment, this does not need to be guarded against as non-powers of 2 will not cause issues beyond the choice of results being reduced.
(cherry picked from commit 18fb1c3866)
Scaling is not expensive, but it does not change either, and this avoids the need for a virtual method call. This cascades back to all GetCharacterHeight(FS_xxx) and FONT_HEIGHT_xxx calls.
(cherry picked from commit 9c6c0a0966)
Replaces constant pixel values with values scaled based on font size.
This allows the industry chain to maintain a consistent look across
different sizes. Previously all except cargo line height were fixed.
(cherry picked from commit 055067c49c)
Both company icon sprite and text now centred within each row, and extra
padding added to avoid the sprites running into each other.
(cherry picked from commit 957beaaefc)
In case a character was encoded in multiple bytes, but required fewer bytes to be encoded, the first byte would be copied to the output leaving an invalid Utf8 encoded string. Later uses of the validated string would use the same decode logic, which would yield a question mark and just read a single byte, so nothing dangerous happened.
Furthermore, because the next byte would not be a first byte of an encoded Utf8 character, the last few valid characters could be removed by the validation as well.
(cherry picked from commit f00564eeb2)
* Fix: 'Cache' top and bottom lines of textfile viewer to avoid overdraw.
The text file viewer calculated the number of lines required to set the scrollbar, but did not retain this information, so this was recalculated on every draw operation. This includes overdrawing text outside the bounds of the current scroll position.
With this change the top and bottom lines for each line of text are remembered, and reflowing is avoided where possible. Text outside the current scroll bounds is not drawn.
Additionally the scroll interval is now based on text lines instead of pixel lines, which increases the text capacity depending on the font size.
* Fix: Limit text viewer to showing 64k lines.
Text files with more than 64k wrapped lines would exceed the scrollbar capacity and cause an assert. This is harder to reach now that the scrollbar counts lines instead of pixels.
(cherry picked from commit 0b460bf4a1)
This happens if the bounding dimensions are changed so that each item is the same size, as happens on the railtype/roadtype dropdown lists, as the vertical offset was calculated before this dimension is changed.
(cherry picked from commit ae7f07de74)