MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / graphGetMaxValue

Function graphGetMaxValue

src/OpenLoco/src/Ui/Chart.cpp:28–64  ·  view source on GitHub ↗

0x004CF869

Source from the content-addressed store, hash-verified

26
27 // 0x004CF869
28 static int64_t graphGetMaxValue(const GraphSettings& gs)
29 {
30 int64_t maxValue = 0;
31 for (auto lineIndex = 0U; lineIndex < gs.lineCount; lineIndex++)
32 {
33 auto dataIndex = 0U;
34 std::byte* dataPtr = gs.yData[lineIndex];
35 if ((gs.flags & GraphFlags::dataFrontToBack) != GraphFlags::none)
36 {
37 dataIndex = gs.dataStart[lineIndex];
38 dataPtr = &dataPtr[gs.dataTypeSize * (gs.dataEnd - dataIndex)];
39 }
40
41 while (dataIndex < gs.dataEnd)
42 {
43 // Data front-to-back?
44 // NB: all charts except cargo delivery
45 if ((gs.flags & GraphFlags::dataFrontToBack) != GraphFlags::none)
46 {
47 dataPtr -= gs.dataTypeSize;
48 }
49
50 int64_t value = graphGetValueFromPointer(dataPtr, gs.dataTypeSize);
51 maxValue = std::max(maxValue, std::abs(value));
52 dataIndex++;
53
54 // Data back-to-front?
55 // NB: for cargo delivery chart
56 if ((gs.flags & GraphFlags::dataFrontToBack) == GraphFlags::none)
57 {
58 dataPtr += gs.dataTypeSize;
59 }
60 }
61 }
62
63 return maxValue;
64 }
65
66 // 0x004CFA49
67 static void graphDrawAxesAndLabels(const GraphSettings& gs, Window& self, Gfx::DrawingContext& drawingCtx)

Callers 1

drawGraphFunction · 0.85

Calls 1

graphGetValueFromPointerFunction · 0.85

Tested by

no test coverage detected