Fix #22304: Graphs don't draw lines on the left edge of the screen (#22315)

This commit is contained in:
mrmbernardi 2024-07-17 02:01:11 +10:00 committed by GitHub
parent 4a981be643
commit 461b4b9669
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View file

@ -11,6 +11,7 @@
- Fix: [#19210] The load/save window executes the loading code twice, resulting in a slowdown.
- Fix: [#22056] Potential crash upon exiting the game.
- Fix: [#22208] Cursor may fail to register hits in some cases (original bug).
- Fix: [#22304] Graphs don't draw lines on the left edge of the screen.
0.4.12 (2024-07-07)
------------------------------------------------------------------------

View file

@ -186,7 +186,8 @@ namespace Graph
DrawPixelInfo& dpi, const money64* history, int32_t count, const ScreenCoordsXY& origCoords, int32_t modifier,
int32_t offset)
{
auto lastCoords = ScreenCoordsXY{ -1, -1 };
ScreenCoordsXY lastCoords;
bool lastCoordsValid = false;
auto coords = origCoords;
for (int32_t i = count - 1; i >= 0; i--)
{
@ -194,7 +195,7 @@ namespace Graph
{
coords.y = origCoords.y + 170 - 6 - ((((history[i] >> modifier) + offset) * 170) / 256);
if (lastCoords.x != -1)
if (lastCoordsValid)
{
auto leftTop1 = lastCoords + ScreenCoordsXY{ 1, 1 };
auto rightBottom1 = coords + ScreenCoordsXY{ 1, 1 };
@ -207,6 +208,7 @@ namespace Graph
GfxFillRect(dpi, { coords, coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
lastCoords = coords;
lastCoordsValid = true;
}
coords.x += 6;
}
@ -216,7 +218,8 @@ namespace Graph
DrawPixelInfo& dpi, const money64* history, int32_t count, const ScreenCoordsXY& origCoords, int32_t modifier,
int32_t offset)
{
auto lastCoords = ScreenCoordsXY{ -1, -1 };
ScreenCoordsXY lastCoords;
bool lastCoordsValid = false;
auto coords = origCoords;
for (int32_t i = count - 1; i >= 0; i--)
{
@ -224,7 +227,7 @@ namespace Graph
{
coords.y = origCoords.y + 170 - 6 - ((((history[i] >> modifier) + offset) * 170) / 256);
if (lastCoords.x != -1)
if (lastCoordsValid)
{
auto leftTop = lastCoords;
auto rightBottom = coords;
@ -234,6 +237,7 @@ namespace Graph
GfxFillRect(dpi, { coords - ScreenCoordsXY{ 1, 1 }, coords + ScreenCoordsXY{ 1, 1 } }, PALETTE_INDEX_21);
lastCoords = coords;
lastCoordsValid = true;
}
coords.x += 6;
}